How to copy / add files to the user's home directory in the main directory of the container?

# Update

I just realized that the ADD / COPY command does not allow access to files or directories outside of the current working directory on the host. One more thing: if you give an absolute file / directory path as the source path after the ADD / COPY command, this will not be allowed either.

Please refer to this and have fun with the hack! :)

=============================================== === ======================

I would like to copy / add files from the user's home directory on the host to the container's home directory for the same user.

First of all, the user can be changed as the user who builds the docker image with the Dockerfile on each host. For example, on my host, I have a custom "test". The newbie user appears on the other person's host. On each host, my Dockerfile will be created / used.

Below 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 Dockerfile the following error is displayed.

Step 43/44 : ADD /home/user/.ssh/id_rsa* /home/${USER}/.ssh/
No source files were specified

      

Please kindly advise me to do what I want. :) Thanks.

+3


source to share


1 answer


you can use the following:



WORKDIR /home COPY ${pwd}/my-file.txt .

-2


source







All Articles