Docker for Windows: Sharing Host Volumes
I’ve been playing with the new “Docker for Windows” tool recently, and I wanted to share a slightly obscure issue I ran across.
Docker lets you share volumes between your containers and your host machine. This is handy during development time, when you want to be able to quickly iterate without having to continually rebuild your container.
The Suspicious Empty Directory
When I first tried sharing a volume, I typed this into PowerShell:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Hmm… As you can see, the c:\docker
folder has a test file, but it doesn’t show up in the Docker container.
After some head scratching, I figured out the missing piece: Out of the box, Docker isn’t configured with permissions to share your drives with your containers.
Giving Docker Access
To give Docker access to your computer’s drives, right click on the Docker icon in your taskbar, then click “Settings…”
Under the “Shared Drives” section, check the drives you’d like to share, then click “Apply”
Docker will ask you for credentials, which it uses to access the drives.
(Note that if you log into your computer with a Windows Live account, your username should be something like “MicrosoftAccount\you@live.com”)
Once you save your credentials, you should be able to share volumes from your host computer to your containers.
1 2 3 4 |
|