Pretty much the title says it all. I know I can copy the file (from the host) into a docker container. I also know I can copy the directory into a docker container. But how to copy the contents of a directory (preserving all subdirectories) into a directory in a docker container?
On my host I have a directory called src
. On the docker container I have a directory /var/www/html
. That src
has both files and directories. I need all of them to be copied (with the command) into the container; not bound, not mounted, but copied.
It sounds like a trivial operation, but I've tried so many ways and couldn't find anything online that works! Ideally, it would be best if that copy operation would work every time I run the docker-compose up -d
command.
Thanks in advance!
I found the solution. There is a way of specifying the context directory explicitly; in that case the dockerfile also need to be specified explicitly too.
In the docker-compose.yml one should have the following structure:
In this case the
src
is "visible" because it is inside the context! Then in that Dockerfile the COPY command will work!Update: There is another way to achieve this via the command as well. However for me it started to work when I've added the
./
at the end. So the full command is: