Docker Community Forums

Share and learn in the Docker community.

Mount local folder and its sub-directories

beginner question. I usually mount a local folder with

docker run -v /path/to/local/fold:/path/in/container -t testimg

However it looks like the folders in the /path/to/local/fold (something like /path/to/local/fold/dir) are not there from the container (/path/in/container/fold/dir). So question is: are sub-directories mounted automatically or I need to do something else? Could not find an answer.

Thank you

docker run -v ~/path/to/local/fold:/path/in/container -t testimg

instead of
docker run -v /path/to/local/fold:/path/in/container -t testimg

solved the issue.

Hi :slight_smile:

When using mounts like this, the local dir, is always the master, so whatever is in the local dir, is replicated to the container.

So if you have files in your container, in /path/in/container, these files/folders will disappear when you mount it to a local dir.