Skip to content
This repository has been archived by the owner on Apr 28, 2018. It is now read-only.

Mounted folder appears empty using Docker-PowerShell; fine with 'docker' #178

Open
festus1973 opened this issue Feb 4, 2017 · 1 comment

Comments

@festus1973
Copy link

The following command executes successfully and I'm able to view my host directory "C:\temp" as "C:\scripts" on the container:

docker run -it -d --name festus -v c:\temp:c:\scripts core_usr_img

...but when performing the same action using the PowerShell module as follows...

$config = [Docker.DotNet.Models.Config]::new();
$config.Hostname="festus";
$dict = new-object 'system.collections.generic.dictionary[string,object]';
$dict.Add("C:\temp:c:\scripts",$null);
$config.Volumes = $dict;
$config;
Run-ContainerImage "core_usr_img" -Configuration $config -name "festus" -Detach -input

...the container starts up, 'scripts' appears as a folder in c:, but it's empty. The container can't see the contents of the folder. Again, this works just fine using the raw 'docker' call. Only when using the PowerShell module does this bug occur. Any ideas?

@festus1973
Copy link
Author

Just a follow-up on this in case anyone else encounters the same thing. Mounting a host directory actually calls for use of the HostConfig class, not Config as indicated in some of the other forum posts here. Further, it's the 'Bind' property, not 'Volumes' that should be used to construct the mount. The follow revised script works and the directory is now visible from the container:

$config = [Docker.DotNet.Models.HostConfig]::new();
$config.Binds= new-object 'system.collections.generic.list[string]';
$config.Binds.Add("c:\temp:c:\scripts");
Run-ContainerImage "core_usr_img" -name "festus" -Detach -input -HostConfiguration $config

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant