Mounting a folder to a Docker container allows you to share data back and forth on your host system. It’s a great feature to have especially on Windows where command line editors are not as native to the OS as they are with Unix/Linux.

Docker environment

Your mileage may vary with the information cited in this article depending on the version of Docker you are using. My setup at the time of this writing is…

Mounting Windows file paths

There are numerous articles available on how to mount folders inside of Docker images.

On Windows…

And mounting in general…

Though many articles cite different methods for referencing paths.

Referencing Windows paths

It’s likely that the way to reference Windows paths has changed over time and for different versions of Docker. I’m not entirely certain and have not researched it in depth but here is a capture of the different folder path formats I’ve encountered

//c/myFolder
/c/myFolder
c:\myFolder

Of all the pathing styles the last one is the format that worked for me…

docker run -it --name myDockerContainer1 --mount src=C:\myFolder,dst=c:\myDockerMount,type=bind aDockerImage:latest

If a path has spaces you can use quotes to contain it…

docker run -it --name myDockerContainer1 --mount src="C:\myFolder\sub folder",dst=c:\myDockerMount,type=bind aDockerImage:latest

Conclusions

  • An absolute path must be used when specifying folders
  • Use quotes around a path if it contains spaces