ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
实例:构造centos7镜像,该镜像中同时包含vim、net相关命令 ``` FROM centos:7 MAINTAINER lcy<1056138261@qq.com> ENV MYPATH /usr/local WORKDIR $MYPATH RUN yum -y install vim \ && yum -y install net-tools EXPOSE 80 CMD echo $MYPATH CMD echo "----end----" CMD /bin/bash ``` 执行,由于centos7镜像已经存在,因此不需要下载 ``` [root@iZbp1bum6107bp8mgzkeunZ example4-centos]# docker build -f Dockerfile -t mycentos:1.0 . Sending build context to Docker daemon 2.048kB Step 1/9 : FROM centos:7 ---> eeb6ee3f44bd Step 2/9 : MAINTAINER lcy<1056138261@qq.com> ---> Running in c5993c0e70a2 Removing intermediate container c5993c0e70a2 ---> be957a5948b4 Step 3/9 : ENV MYPATH /usr/local ---> Running in adff69d0c294 Removing intermediate container adff69d0c294 ---> d81f2ae67520 Step 4/9 : WORKDIR $MYPATH ---> Running in adc41f6dd442 Removing intermediate container adc41f6dd442 ---> 1e20c47cf4d3 Step 5/9 : RUN yum -y install vim && yum -y install net-tools ---> Running in 78e69d79f10e Loaded plugins: fastestmirror, ovl Determining fastest mirrors * base: ftp.sjtu.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.163.com ... ... Successfully built c0294bb764ed Successfully tagged mycentos:1.0 // 查看镜像是否存在 [root@iZbp1bum6107bp8mgzkeunZ example4-centos]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mycentos 1.0 c0294bb764ed 10 seconds ago 426MB centos 7 eeb6ee3f44bd 6 months ago 204MB // 运行进入,发现此时默认的目录为dockerfile中设置的工作目录 [root@iZbp1bum6107bp8mgzkeunZ example4-centos]# docker run -it mycentos:1.0 [root@87221bf3dc1c local]# pwd /usr/local [root@87221bf3dc1c local]# ```