新建mydockerfile
FROM centos
MAINTAINER lh<aaa@163.com>
ENV MYPATH /usr/local
WORKDIR $MYPATH
EXPOSE 80
CMD echo $MYPATH
CMD yum -y install vim
EXPOSE 80
CMD echo $MYPATH
CMD echo "------END------"
CMD /bin/bash
构建镜像
lh@lh-pc:~/dockerfile$ docker build -f mydockerfile -t mycentos:0.1 .
lh@lh-pc:~/dockerfile$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mycentos 0.1 4bd044279345 2 minutes ago 231MB
测试运行镜像
docker run -it mycentos:0.1 /bin/bash
查看镜像的构建过程
docker history 镜像id
lh@lh-pc:~/dockerfile$ docker history 7772b6af6a69
IMAGE CREATED CREATED BY SIZE COMMENT
7772b6af6a69 3 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "/bin… 0B
774142d33d60 3 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "echo… 0B
bc7bc9a2c676 3 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "echo… 0B
13765667da07 3 minutes ago /bin/sh -c #(nop) EXPOSE 80 0B
31b7b9e33e76 3 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "yum … 0B
ec075d903f33 46 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "echo… 0B
eeed3283d442 46 minutes ago /bin/sh -c #(nop) EXPOSE 80 0B
d2c23717be2f 2 hours ago /bin/sh -c #(nop) WORKDIR /usr/local 0B
15029f5abc30 2 hours ago /bin/sh -c #(nop) ENV MYPATH=/usr/local 0B
f148fcbb7846 2 hours ago /bin/sh -c #(nop) MAINTAINER lh<aaa@163.com> 0B
5d0da3dc9764 14 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 14 months ago /bin/sh -c #(nop) LABEL org.label-schema.sc… 0B
<missing> 14 months ago /bin/sh -c #(nop) ADD file:805cb5e15fb6e0bb0… 231MB
image.png
网友评论