Search code examples
dockervolume

Docker - mounted directory is empty inside container


I am attempting to mount a non-empty directory into a container, however, the directory inside the container is empty. The directory does not already exist in the container. My command is:

docker run --volume /tmp:/test busybox:latest ls -l /test

I have also tried this using the --mount flag instead but no success. Why is the /test directory inside my container empty? It should contain the contents of /tmp from the host.


Solution

  • Finally figured things out, in part provoked by @BMitch's comment. I was running Docker in a multi-node environment so Docker was creating the new container on a separate node. I solved the problem by coping the file into the new container via docker cp