简体   繁体   English

在Docker中挂载文件夹:Windows主机,Windows映像

[英]Mounting Folders in Docker: Windows Host, Windows Image

How to use the docker mount option to share a local folder in Docker Container? 如何使用docker mount选项在Docker Container中共享本地文件夹? Currently, I am using this command but I am not being successful. 当前,我正在使用此命令,但没有成功。

docker run --mount source='c:\temp',target='c:\temp' -i newname:latest

I get this error - 我收到此错误-

C:\Program Files\Docker\docker.exe: Error response from daemon: invalid mount config for type "volume": invalid volume name.

My environment: Host: Windows Server, version 1709 Docker Container: Windows Server Core, v1709 我的环境:主机:Windows Server,版本1709 Docker容器:Windows Server Core,版本1709

You need to use bind mount. 您需要使用bind安装。 Example below maps your host directory c:\\users\\public\\ to the one which is inside container c:\\users\\public and then outputs content of that directory. 下面的示例将您的host目录c:\\users\\public\\映射到容器c:\\users\\public内的host目录,然后输出该目录的内容。

 PS C:\\Users\\gsuvalia> docker run --rm --mount type=bind,source=c:\\users\\public\\,destination=c:\\users\\public\\ microsoft/nanoserver powershell get-childitem c:\\users\\public Directory: C:\\users\\public Mode LastWriteTime Length Name ---- ------------- ------ ---- dr--- 12/1/2017 10:16 PM Documents dr--- 7/16/2016 6:47 AM Downloads dr--- 7/16/2016 6:47 AM Music dr--- 12/1/2017 10:16 PM Pictures d----- 8/22/2017 10:26 PM Roaming dr--- 7/16/2016 6:47 AM Videos 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM