Sharing your C drive with Docker for Windows when using Azure Active Directory

Summary

If you login to your PC using Azure Active Directory (AzureAD/AAD) and try to share your C drive in Docker for Windows, it doesn't work. This article shows you how to fix it. If you haven't yet tried to install Docker for Windows, try reading my guide to Getting started with Docker for Windows (which links back to this one at the requisite juncture1).

Background

If you're using Azure Active Directory to sign in to your Windows 10 PC (I do this through my Office 365 account which I use for my consultancy business) then, when you tried to share your C drive when installing Docker for Windows, it will have gone wrong.

Specifically, it will have prompted you for your credentials like this:

Docker Azure AD Credentials Prompt

And then, if you got them right, it will just seem to have ignored you and unchecked the share, without telling you that anything went wrong.

A look in the logs will show something like this:

[21:31:23.242][SambaShare     ][Info   ] Mount C
[21:31:23.268][Cmd            ][Info   ] This shared resource does not exist.
[21:31:23.268][Cmd            ][Info   ] More help is available by typing NET HELPMSG 2310.
[21:31:23.272][SambaShare     ][Info   ] "C" is not shared
[21:31:23.272][SambaShare     ][Info   ] Creating share "C:\" as "C" with Full Control to "TomChantler"
[21:31:23.301][Cmd            ][Info   ] System error 1332 has occurred.
[21:31:23.302][Cmd            ][Info   ] No mapping between account names and security IDs was done.
[21:31:23.305][SambaShare     ][Error  ] Failed to create share "C:\" as "C" with Full Control to "TomChantler" with code: 2
[21:31:23.334][Cmd            ][Info   ] This shared resource does not exist.
[21:31:23.335][Cmd            ][Info   ] More help is available by typing NET HELPMSG 2310.
[21:31:23.338][NamedPipeClient][Info   ] Received response for Mount
[21:31:23.338][SambaShare     ][Info   ] "C" is not shared

Apparently this is a known issue.

Procedure

So far, the only way I have found to fix it is to create a new user account which is the same as your AzureAD account, but without the AzureAD prefix. e.g. If your account is AzureAD\TomChantler then you need to create a local account called TomChantler.

  1. Open Settings and navigate to Accounts → Other people → Add User to this PC → I don't have this person's sign-in information → Add a user without a Microsoft account → Create an account for this PC and enter the username. I gave the same password as my AzureAD password, although I'm not sure if this was necessary.
  2. Make the new account be an Administrator of the machine.
  3. When you've finished the account should look like this:

Computer accounts showing local and AzureAD side-by-side

Now try the share again in Docker. If you have previously authenticated then it won't ask you for your credentials. It will just work and the checkbox will remain checked.

Share drive in Docker

Let's check the logs to be sure.

[21:42:01.320][SambaShare     ][Info   ] Mount C
[21:42:01.361][Cmd            ][Info   ] Share name        C
[21:42:01.361][Cmd            ][Info   ] Path              C:\
[21:42:01.361][Cmd            ][Info   ] Remark            
[21:42:01.361][Cmd            ][Info   ] Maximum users     No limit
[21:42:01.361][Cmd            ][Info   ] Users             TomChantler          
[21:42:01.361][Cmd            ][Info   ] Caching           Caching disabled
[21:42:01.362][Cmd            ][Info   ] Permission        TC-7200U\TomChantler, FULL
[21:42:01.362][Cmd            ][Info   ] The command completed successfully.
[21:42:01.372][SambaShare     ][Info   ] "C" is shared
[21:42:01.419][SambaShare     ][Info   ] Username: TomChantler
[21:42:01.419][SambaShare     ][Info   ] Host IP: 10.0.75.1

Great. Everything is now working as it should.

If you came here whilst in the middle of installing Docker for Windows, you can carry on with the rest of my guide, which also includes the reasons I am using it.


  1. This is how I speak in real life.


image credit: me