标签:end mes ali cmd 启动 ima try osi eating
文章源自Katacoda Docker Playground的学习
1 # Creating a Dockerfile 2 $ vim Dockerfile 3 FROM nginx:1.11-alpine
RUN <command> allows you to execute any command
COPY <src> <dest> copy local file to container
1 # Creating a Dockerfile 2 $ vim Dockerfile 3 FROM nginx:1.11-alpine 4 COPY index.html /usr/share/nginx/html/index.html
EXPOSE <port> 是声明运行时容器提供服务端口
1 # Creating a Dockerfile 2 $ vim Dockerfile 3 FROM nginx:1.11-alpine 4 COPY index.html /usr/share/nginx/html/index.html 5 EXPOSE 80
文中的意思是CMD是在容器启动后开始执行,为什么要用default command没理解,下次看官方文档学
还有一个跟CMD类似的命令ENTRYPOINT
1 # Creating a Dockerfile 2 $ vim Dockerfile 3 FROM nginx:1.11-alpine 4 COPY index.html /usr/share/nginx/html/index.html 5 EXPOSE 80 6 CMD ["nginx", "-g", "daemon off;"]
1 $ docker build -t my-nginx-image:latest . 2 Sending build context to Docker daemon 3.072kB 3 Step 1/4 : FROM nginx:1.11-alpine 4 ---> bedece1f06cc 5 Step 2/4 : COPY index.html /usr/share/nginx/html/index.html 6 ---> 5e7ec77f11f5 7 Step 3/4 : EXPOSE 80 8 ---> Running in bbba47274f20 9 Removing intermediate container bbba47274f20 10 ---> 2affd960d187 11 Step 4/4 : CMD ["nginx", "-g", "daemon off;"] 12 ---> Running in 1763dbb56315 13 Removing intermediate container 1763dbb56315 14 ---> 7d389eab8621 15 Successfully built 7d389eab8621 16 Successfully tagged my-nginx-image:latest 17 18 $ docker images 19 REPOSITORY TAG IMAGE ID CREATED SIZE 20 nginx 1.11-alpine bedece1f06cc 3 years ago 54.3MB
1 $ docker run -d -p 80:80 my-nginx-image:latest 2 379c8748a3415a1ddd019f119cb1d5a201419ea8e403200a802bbd6030c86c6e 3 4 $ curl -i http://docker 5 HTTP/1.1 200 OK 6 Server: nginx/1.11.13 7 Date: Thu, 30 Apr 2020 15:48:19 GMT 8 Content-Type: text/html 9 Content-Length: 21 10 Last-Modified: Thu, 30 Apr 2020 15:45:11 GMT 11 Connection: keep-alive 12 ETag: "5eaaf287-15" 13 Accept-Ranges: bytes 14 15 <h1>Hello World</h1> 16 17 $ docker ps 18 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 19 379c8748a341 my-nginx-image:latest "nginx -g ‘daemon of…" 40 seconds ago Up 38 seconds 0.0.0.0:80->80/tcp, 443/tcp hungry_payne
标签:end mes ali cmd 启动 ima try osi eating
原文地址:https://www.cnblogs.com/Vito-L/p/building-container-images.html