创建dockerfile文件
pwd
vim Dockerfile
FROM nginx
RUN echo "我要学docker" > /usr/share/nginx/html/index.html
构建并运行
docker build .
docker tag 容器id my-nginx
docker run -d -p 80:80 my-nginx
cmd和entrypoint的区别
#创建一个dockerfile
FROM centos:7.8.2003
RUN rpm --rebuilddb && yum install epel-release -y
RUN rpm --rebuilddb && yum install epel-release -y
CMD ["curl","-s","http://ipinfo.io/ip"]
#构建容器
docker build .
#运行容器
docker tag 容器id my_centos_curl_cmd
docker run my_centos_cmd_curl
#修改dockerfile
#将CMD改成ENTRYPOINT
ENTRYPOINT ["curl","-s","http://ipinfo.io/ip"]
#构建容器
docker build .
#运行容器
docker tag 容器id my_centos_curl_en
docker run my_centos_cmd_curl -i