dockermountshared-directory

Unable to share a local windows path with a container in Docker


New to Docker, and running Docker Toolbox on Win 10 x64.

I'm trying to share (mount) a local Windows path with a container (Portainer in this case) so that the container will save all of it's config settings, locally on my PC, so that I can always upgrade the container while still having it's configuration persistant.

I have read/watched many tutorials, reference, docs, vids, etc., I'm trying to do what they seem to explain to do, but when I create the container with the local path mounted and then go into the container, set some config settings, and then look at the windows path I had mounted, there's nothing being saved there.

Not sure what the problem is?

Here's an example docker cmd I'm running:

docker run -it -v /c/Servers/DockerConfigs/Portainer:/data :P portainer/portainer

To my understanding, whatever gets stored in the /data folder in the container should also get saved to the Windows folder on the host C:\Servers\DockerConfigs\Portainer, but nothing is getting saved to that windows folder ...

I've also tried copying some files on the host to that windows folder, and then within the container viewing the /data folder to see if they show up using ls -a but again, nothing shows up in there ...

Anyone know what I'm missing?


Solution

  • Finally found out the answer thanks to this thread: How to mount a host directory in a Docker container

    Turns out the easiest way (on Windows) is to make sure to mount your folders from your Users directory, and use the --mount command when starting the container.

    i.e.

    docker run -P -it --name organizr --mount src="/c/Users/My PC/AppData/Roaming/DockerConfigs/Organizr",dst=/config,type=bind organizrtools/organizr-v2:latest