Docker Community Forums

Share and learn in the Docker community.

Is there a way to share drives via command line?

(Gdouaire) #1

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.

(Gdouaire) #2

I may have found something here:, under section “Mounting Volumes”

(Gdouaire) #3

Mostly based on the link shared above:

For instance, I want to share drives within this context:

username: johndoe
password: qwerty
Drives to share: C and D

Add credentials to Credentials Manager

Cmdkey.exe /generic:"Docker Host Filesystem Access" /user:DOMAIN\johndoe /pass:qwerty

Share drives as required

net share C=C:\ /grant:johndoe,FULL /CACHE:None
net share D=D:\ /grant:johndoe,FULL /CACHE:None

This is where it gets tricky… setting up data for the guest VM to obtain the credentials…

I should be adding a HostExchangeItem under this, but don’t know how to do it:

$VmMgmt = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_VirtualSystemManagementService
$vm = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter {ElementName='MobyLinuxVM'}

($vm.GetRelated("Msvm_KvpExchangeComponent")[0] ).GetRelated("Msvm_KvpExchangeComponentSettingData").HostExchangeItems | % { $GuestExchangeItemXml = ([XML]$_).SelectSingleNode("/INSTANCE/PROPERTY[@NAME='Name']/VALUE[child::text() = 'cifsmount']") 
        if ($GuestExchangeItemXml -ne $null) 

(Gdouaire) #4

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 !

(Tomasfejfar) #5

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.