我正在使用Ubuntu 18.04.1 LTS
使用Docker version 18.09.0, build 4d60db4
。
Docker文件
FROM registry.hub.docker.com/verdaccio/verdaccio
RUN echo "whoami" && whoami
RUN echo "echo \$HOME" && echo $HOME
RUN mkdir -p $HOME/my_dir
WORKDIR $HOME/my_dir
COPY ./my_verdaccio.conf.yaml $HOME/my_dir/my_verdaccio.conf.yaml
RUN echo "pwd && ls -la" && pwd && ls -la
RUN echo "echo \$HOME && ls -la \$HOME" && echo $HOME && ls -la $HOME
RUN echo "echo \$HOME/my_dir && ls -la \$HOME/my_dir" && echo $HOME/my_dir && ls -la $HOME/my_dir
CMD $APPDIR/bin/verdaccio --config $HOME/my_dir/my_verdaccio.conf.yaml --listen $PROTOCOL://0.0.0.0:${PORT}
建立输出
$ docker build -t my_test -f Dockerfile.test my_dir/
Sending build context to Docker daemon 1.834MB
Step 1/10 : FROM registry.hub.docker.com/verdaccio/verdaccio
---> 721ec0ff4795
Step 2/10 : RUN echo "whoami" && whoami
---> Running in 259851ba7eaa
whoami
verdaccio
Removing intermediate container 259851ba7eaa
---> 822165aeff40
Step 3/10 : RUN echo "echo \$HOME" && echo $HOME
---> Running in f2199c917ed8
echo $HOME
/home/verdaccio
Removing intermediate container f2199c917ed8
---> 9fa74aa672ec
Step 4/10 : RUN mkdir -p $HOME/my_dir
---> Running in a9072d9bfabb
Removing intermediate container a9072d9bfabb
---> 297ba12349fc
Step 5/10 : WORKDIR $HOME/my_dir
---> Running in 1966dddaea2e
Removing intermediate container 1966dddaea2e
---> 955bb4903b14
Step 6/10 : COPY ./my_verdaccio.conf.yaml $HOME/my_dir/my_verdaccio.conf.yaml
---> abcddd168468
Step 7/10 : RUN echo "pwd && ls -la" && pwd && ls -la
---> Running in 08a2be791971
pwd && ls -la
/my_dir
total 12
drwxr-xr-x 1 root root 4096 Dec 3 17:47 .
drwxr-xr-x 1 root root 4096 Dec 3 17:47 ..
-rw-rw-r-- 1 root root 1927 Dec 3 16:16 my_verdaccio.conf.yaml
Removing intermediate container 08a2be791971
---> 10aa4c1774b2
Step 8/10 : RUN echo "echo \$HOME && ls -la \$HOME" && echo $HOME && ls -la $HOME
---> Running in 054c7c857d0d
echo $HOME && ls -la $HOME
/home/verdaccio
total 12
drwxr-sr-x 1 verdacci verdacci 4096 Dec 3 17:47 .
drwxr-xr-x 1 root root 4096 Nov 15 19:58 ..
drwxr-sr-x 2 verdacci verdacci 4096 Dec 3 17:47 my_dir
Removing intermediate container 054c7c857d0d
---> fe11c625ee85
Step 9/10 : RUN echo "echo \$HOME/my_dir && ls -la \$HOME/my_dir" && echo $HOME/my_dir && ls -la $HOME/my_dir
---> Running in 887cd2eaa002
echo $HOME/my_dir && ls -la $HOME/my_dir
/home/verdaccio/my_dir
total 8
drwxr-sr-x 2 verdacci verdacci 4096 Dec 3 17:47 .
drwxr-sr-x 1 verdacci verdacci 4096 Dec 3 17:47 ..
Removing intermediate container 887cd2eaa002
---> 6808c030fa5a
Step 10/10 : CMD $APPDIR/bin/verdaccio --config $HOME/my_dir/my_verdaccio.conf.yaml --listen $PROTOCOL://0.0.0.0:${PORT}
---> Running in e4e9a35b36cb
Removing intermediate container e4e9a35b36cb
---> 47e25b18af95
Successfully built 47e25b18af95
Successfully tagged my_test:latest
为什么将
my_verdaccio.conf.yaml
复制到/my_dir
而不复制到/home/verdaccio/my_dir
?为什么
pwd
指向/my_dir
,为什么还要创建/my_dir
?verdaccio
的Dockerfile:https://github.com/verdaccio/verdaccio/blob/master/Dockerfile。 最佳答案
尝试设定ENV HOME /root/ <Or your home directory>
在运行RUN mkdir -p $HOME/my_dir
之前在dockerfile中