Intermittent problem accessing network share from inside Windows 2016 container

I have several windows containers that need to access a common network share. First I tried using the docker volume mapping to map to the shared windows folder, which is located on a separate machine. I had nothing but problems with this approach and was unable to make it work. In order to workaround this problem, I found that I could simply map a drive inside the container using the “New-PSDrive” command in powershell. This is working most of the time, but sometimes it refuses to work. My script waits 30 seconds and retries the “New-PSDrive” command if it fails. I sometimes get a container that never succeeds in mapping the drive.

When this last happened, I used exec to run powershell in the container, and found that the “net use” command was also failing. Here is the error I get:

PS C:> net use \\WIN-XXXXXX\sbm
System error 1231 has occurred.

The network location cannot be reached. For information about network troubleshooting, see Windows Help

PS C:>

Trying “net view” also results in an error:

PS C:> net view \\WIN-XXXXXX
The Server service is not started.

More help is available by typing NET HELPMSG 2114.

PS C:>

On containers that are not showing this problem, both the “net use” and “net view” commands work correctly. Does anyone have any suggestions of how to fix this, or knowledge of why it would only fail intermittently?

I’m running the containers on AWS Windows 2016 EC2 instances.

I recommend you look at Windows Server 2016 core 1709, which includes global SMB file share mapping support. I’ve tried this and it works great. See: