I just realized that ADD/COPY command doesn't permit any access to files or directories outside of current working directory in host. One more thing is that if you specify an absolute path of file/directory as a source path after ADD/COPY command, it'll also not be permitted.
Please refer to this and have happy hacking ! :)
=======================================================================
I would like to copy/add files under a user's home directory in host into the container's home directory for the same user.
First of all, a user can be changed as the user who is building a docker image with Dockerfile on each host. For instance, in my host, I have a user "test". In the other person's host, there will be a user "newbie". In each host, my Dockerfile will be built/used.
The following is my test syntax for copying/adding files.
...
RUN mkdir -p /home/${USER}/.ssh
ADD /home/${USER}/.ssh/id_rsa* /home/${USER}/.ssh/
or COPY /home/${USER}/.ssh/id_rsa* /home/${USER}/.ssh/
...
When I try to build this Docker file, the following error is displayed.
Step 43/44 : ADD /home/user/.ssh/id_rsa* /home/${USER}/.ssh/
No source files were specified
Please kindly guide me to do what I want to do. :) Thanks.
It has now been two years sice the question has been ask, but I want to cite to official documentation here which states the same as what @Sung-Jin Park already found out.
ADD obeys the following rules:
- The path must be inside the context of the build; you cannot ADD ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.