Docker for Windows: How to use mapped drives as shared drives in docker?

Windows Server 2016 Linux (alpine) containers Docker Version 18.03.1-ce

I have a windows machine which is on an AD Domain, I’m running linux containers and my docker version is 18.03.1-ce. I’m trying to share my drives with docker which are mapped from another machine that is on the same domain. Let’s call this drive z:/ which has UNC path //MILKYWAY/shared_drive

The mapped network drive does not show up in the shared drives. When I use the -v flag to try and map I get a box asking to share my drive, I type my credentials and then it immediately gives me an error. The full error details are below.

I have searched all over the internet for the individual errors, tried just about every solution. Things I’ve tried:

-unc paths
-drive letter paths
-local accounts vs domain accounts
-some crappy plugins
-passwords with/out special characters

Is it not possible to use mapped drives on Windows with linux containers?

[04:39:36.100][NamedPipeServer][Info   ] Version()
[04:39:36.100][NamedPipeServer][Info   ] Version done in 00:00:00.
[04:39:36.101][NamedPipeServer][Info   ] Mount(All, Z, MILKYWAY\<username>:**********, Docker.Core.Settings)
[04:39:36.115][SambaShare     ][Info   ] Mount Z
[04:39:36.180][Cmd            ][Info   ] This shared resource does not exist.
[04:39:36.181][Cmd            ][Info   ] More help is available by typing NET HELPMSG 2310.
[04:39:36.181][SambaShare     ][Info   ] "Z" is not shared
[04:39:36.181][SambaShare     ][Info   ] Creating share "Z:\" as "Z" with Full Control to "MILKYWAY\<username>"
[04:39:36.246][Cmd            ][Info   ] The device or directory does not exist.
[04:39:36.246][Cmd            ][Info   ] More help is available by typing NET HELPMSG 2116.
[04:39:36.247][SambaShare     ][Error  ] Failed to create share "Z:\" as "Z" with Full Control to "MILKYWAY\<username>" with code: 2
[04:39:36.315][Cmd            ][Info   ] This shared resource does not exist.
[04:39:36.315][Cmd            ][Info   ] More help is available by typing NET HELPMSG 2310.
[04:39:36.316][SambaShare     ][Info   ] "Z" is not shared
[04:39:36.332][SambaShare     ][Info   ] Mount Z
[04:39:36.399][Cmd            ][Info   ] This shared resource does not exist.
[04:39:36.400][Cmd            ][Info   ] More help is available by typing NET HELPMSG 2310.
[04:39:36.401][SambaShare     ][Info   ] "Z" is not shared
[04:39:36.401][SambaShare     ][Info   ] Creating share "Z:\" as "Z" with Full Control to "<username>"
[04:39:36.469][Cmd            ][Info   ] The device or directory does not exist.
[04:39:36.469][Cmd            ][Info   ] More help is available by typing NET HELPMSG 2116.
[04:39:36.471][SambaShare     ][Error  ] Failed to create share "Z:\" as "Z" with Full Control to "<username>" with code: 2
[04:39:36.544][Cmd            ][Info   ] This shared resource does not exist.
[04:39:36.544][Cmd            ][Info   ] More help is available by typing NET HELPMSG 2310.
[04:39:36.545][SambaShare     ][Info   ] "Z" is not shared
[04:39:36.545][NamedPipeServer][Info   ] Mount done in 00:00:00.4440492.

I would also like to know an answer to this.

Did anyone figure out how to do this?

I’m also looking for a way to mount UNC paths in my docker container

I see a lot of people with the same question, but no answers :confused:

So, for a Linux container instance running on Windows, that Linux container uses WSL 2, which is essentially a utility VM running Docker. The WSL team documented that here: File Permissions for WSL | Microsoft Learn

Now, specifically for Windows containers, you can leverage SMB mounts today. The documentation is here: Persistent Storage in Containers | Microsoft Learn