[root@dyw219 ~]# mkdir newimg [root@dyw219 ~]# cd newimg [root@dyw219 newimg]#
[root@dyw219 newimg]# vim Dockerfile [root@dyw219 newimg]# cat Dockerfile # mydir comment FROM centos:latest RUN mkdir mydir COPY start.sh mydir/ RUN chmod +x mydir/*.sh
[root@dyw219 newimg]# echo 'date' > start.sh [root@dyw219 newimg]# cat start.sh date
. 表示目前的工作目錄,也可以用絕對目徑。
[root@dyw219 newimg]# docker build -t centos:mydir . Sending build context to Docker daemon 3.072 kB Sending build context to Docker daemon Step 0 : FROM centos:latest ---> ee2526f4865b Step 1 : RUN mkdir mydir ---> Running in ddb205b0b5d0 ---> 40b8cd4293bf Removing intermediate container ddb205b0b5d0 Step 2 : COPY start.sh mydir/ ---> b3203aee6d7f Removing intermediate container d325c1fa9389 Step 3 : RUN chmod +x mydir/*.sh ---> Running in 1263be3c46af ---> 9fe04fab671a Removing intermediate container 1263be3c46af Successfully built 9fe04fab671a