Is there a way to share drives via a command line, other then accessing Settings/Shared Drives UI ? I looked in the documentation, did not find anything on this.
We are deploying several instances running Docker for Windows automatically, but we have not found anything to automate that part.
I guess this is not really something other people are pursuing…
We want to be able to automate our Docker for Windows usage. Some of us out there need to run Docker on Windows as part of build farms. It’s really difficult to achieve right now: there are limitations, such as having to change some settings via the UI only.
Furthermore, when restarting docker service lately, we have got a pop up that asks /Do you recommend Docker for Windows?/ and while the pop up is waiting for an answer, the service is not starting. That is clearly a no-no for unattended/automated Docker for Windows execution !
I have a different use-case, but being able to share from CLI would solve it for me. I’m using file-based BitLocker-encrypted drive for my projects. And docker keeps forgetting that I shared it. I created an issue on github for that. https://github.com/docker/for-win/issues/1650
I’ve had the same problem, plus the docker dialogue doesn’t prompt properly in Windows 10 so it makes it especially difficult.
Would it help to write a script to check for the following? (the reason I ask is that I have done this before and I think I could accomplish the task pretty easily)
Check for a local user dev_agent_1 and if missing create it with some permissions.
2.Check for the docker host access, if missing run:
Cmdkey.exe /generic:“Docker Host Filesystem Access” /user:dev_agent_1 /pass:password
Check for a share, if missing create it using the following:
net share c=c:\ /grant:dev_agent_1,FULL /CACHE:None
Would it also be helpful to run the docker agent service as a particular service?
I know this is years old, but I am pretty desperate, so I may as well make the attempt: did you ever find a solution for this particular problem? If you did, do happen to remember what it was?
Since Docker Desktop can remember that I have shared a drive after I restart Windows, it must be saved somewhere. Is there a settings file or a registry key that can be edited?
When sharing a drive in the UI, the file C:\Users<username>\AppData\Roaming\Docker\settings.json is updated with the section:
“sharedDrives”: {
“C”: true,
“E”: false
}
but that settings file does not list the credentials used to map the drive. The files:
C:\ProgramData\DockerDesktop\vm-data\DockerDesktop.vhdx
C:\Users\All Users\DockerDesktop\vm-data\DockerDesktop.vhdx
are also updated, so maybe the credential information is baked into the VM image files.
It looks like credentials are stored in the windows credentialmanager.
The command “cmdkey /list” gives:
Target: LegacyGeneric:target=Docker Host Filesystem Access
Type: Generic
User: [domain]\[username]
But when I try to add credentials on my own with:
cmdkey /generic:“Docker Host Filesystem Access” /user:[domain]\[username] /pass:[password]
and then start Docker Desktop I get this error:
The parameter is incorrect.
at System.Security.Cryptography.ProtectedData.Unprotect(Byte encryptedData, Byte optionalEntropy, DataProtectionScope scope)
at Docker.WPF.Credentials.MountCredentialAsker.DecryptPassword(Byte encrypted)
at Docker.WPF.Credentials.MountCredentialAsker.RetrieveCredential(String target)
at Docker.Actions.PreStartCheck(ContainerEngineMode engine)
at Docker.Actions.DoStart(SynchronizationContext syncCtx, Boolean showWelcomeWindow, Boolean executeAfterStartCleanup)
at Docker.Actions.<>c__DisplayClass24_0.b__0()
at Docker.ApiServices.TaskQueuing.TaskQueue.<>c__DisplayClass17_0.<.ctor>b__1()
This is also something I am interested in from the standpoint of automated installation and configuration. Did anyone get this working? I am going to attempt the steps detailed above and see whether they now work (I am on the latest build of Windows 10 through the fast channel).
create the mount point outside of the docker container, mount that as described and then directly share that mounted folder as a usual windows (shared) folder