docker 随笔2-----制作docker 镜像
可以拿ubuntu喝alpine作为基础的镜像
ubuntu@ip-172-31-20-162:~$ docker build -t world .
Sending build context to Docker daemon 26.11 kB 发送上下文[当前路径]到docker ,
Step 1 : FROM alpine 用 alphine做基础镜像
---> ee4603260daa
Step 2 : MAINTAINER Junelan <xiuju_lan@foxitsoftware.com>
---> Using cache
---> bcbba0982631
Step 3 : RUN date > /world.txt 当前日期放入
---> Using cache
---> 1d3015bb3860
Step 4 : RUN echo hello >>/world.txt hello 追加进去
---> Using cache
---> a2904eba261b
Step 5 : RUN echo world >>/world.txt world追加进去
---> Running in f34d215dfd78
---> 8496cf6fcdd7
Removing intermediate container f34d215dfd78
Step 6 : CMD cat /world.txt 表示运行这个镜像容器的时候的时候,如果不加任何参数就运行cat 这个命令
---> Running in 27a485ce9fbf
---> 945655752b9d
Removing intermediate container 27a485ce9fbf
Successfully built 945655752b9d 最后生成一个945655752b9d的imageid
从上面看,每个imageid都是基于上个imageid
ubuntu@ip-172-31-20-162:~$ cat Dockerfile
FROM alpine
MAINTAINER Junelan <xiuju_lan@foxitsoftware.com>
RUN date > /world.txt
RUN echo hello >>/world.txt
RUN echo world >>/world.txt
CMD cat /world.txt
查看本地的images 会发现这个时候多了个images出来了,history可以看到镜像的历史。
0b 说明 该步骤 没有为该镜像提供任何的数据
运行下这个镜像,如果没有其他的参数,就默认运行cmd
2..查看别人的dockerfile
ENV NGINX_VERSION 1.11.4-1~jessie 环境变量,EXPOSE 80 443 暴露的端口
FROM debian:jessie MAINTAINER NGINX Docker Maintainers "docker-maint@nginx.com" ENV NGINX_VERSION 1.11.4-1~jessie RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \ && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \ && apt-get update \ && apt-get install --no-install-recommends --no-install-suggests -y \ ca-certificates \ nginx=${NGINX_VERSION} \ nginx-module-xslt \ nginx-module-geoip \ nginx-module-image-filter \ nginx-module-perl \ nginx-module-njs \ gettext-base \ && rm -rf /var/lib/apt/lists/* # forward request and error logs to docker log collector RUN ln -sf /dev/stdout /var/log/nginx/access.log \ && ln -sf /dev/stderr /var/log/nginx/error.log EXPOSE 80 443 CMD ["nginx", "-g", "daemon off;"]