Dockerfile指令
测试
例如官方镜像没有vi ifconfig命令
[root@zhang ~]# docker run -it --name centos_test centos
[root@b3867159d5d9 /]# pwd
/
[root@b3867159d5d9 /]# vim
bash: vim: command not found
[root@b3867159d5d9 /]# ifconfig
bash: ifconfig: command not found
[root@zhang dockerfile]# vim mydockerfile
[root@zhang dockerfile]# cat mydockerfile
FROM centos
MAINTAINER zhang<1552039982>
ENV MYPATH /usr/local
WORKDIR $MYPATH
RUN yum -y install vim
RUN yum -y install net-tools
EXPOSE 80
CMD echo $MYPATH
CMD echo "--------end--------"
CMD /bin/bash
[root@zhang dockerfile]# docker build -f mydockerfile -t mycentos:0.1 .
docker history 镜像id
可以查看镜像的构建过程
[root@zhang dockerfile]# docker history mysql
IMAGE CREATED CREATED BY SIZE COMMENT
0627ec6901db 3 weeks ago /bin/sh -c #(nop) CMD ["mysqld"] 0B
<missing> 3 weeks ago /bin/sh -c #(nop) EXPOSE 3306 33060 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ENTRYPOINT ["docker-entry… 0B
<missing> 3 weeks ago /bin/sh -c ln -s usr/local/bin/docker-entryp… 34B
<missing> 3 weeks ago /bin/sh -c #(nop) COPY file:345a22fe55d3e678… 14.5kB
<missing> 3 weeks ago /bin/sh -c #(nop) COPY dir:2e040acc386ebd23b… 1.12kB
<missing> 3 weeks ago /bin/sh -c #(nop) VOLUME [/var/lib/mysql] 0B
<missing> 3 weeks ago /bin/sh -c { echo mysql-community-server m… 420MB
<missing> 3 weeks ago /bin/sh -c echo 'deb http://repo.mysql.com/a… 55B
<missing> 3 weeks ago /bin/sh -c #(nop) ENV MYSQL_VERSION=8.0.24-… 0B
<missing> 4 weeks ago /bin/sh -c #(nop) ENV MYSQL_MAJOR=8.0 0B
<missing> 4 weeks ago /bin/sh -c set -ex; key='A4A9406876FCBD3C45… 2.61kB
<missing> 4 weeks ago /bin/sh -c apt-get update && apt-get install… 52.2MB
<missing> 4 weeks ago /bin/sh -c mkdir /docker-entrypoint-initdb.d 0B
<missing> 4 weeks ago /bin/sh -c set -eux; savedAptMark="$(apt-ma… 4.17MB
<missing> 4 weeks ago /bin/sh -c #(nop) ENV GOSU_VERSION=1.12 0B
<missing> 4 weeks ago /bin/sh -c apt-get update && apt-get install… 9.34MB
<missing> 4 weeks ago /bin/sh -c groupadd -r mysql && useradd -r -… 329kB
<missing> 4 weeks ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 4 weeks ago /bin/sh -c #(nop) ADD file:c855b3c65f5ba94d5… 69.3MB
学习参考狂神说java