[英]Mount a volume to a container in WSL for Docker 18.03
So since the release of Docker v18.03 I have been unable to mount a volume to a container in WSL. 因此,自从Docker v18.03发布以来,我无法将卷安装到WSL中的容器中。 Previously all I had to do was mount my
/mnt/c
to /c
ie sudo mount --bind /mnt/c
then just run docker run -t image_name:latest -v /c/Users/quantik/path/to/volume:/path/in/container
and this would work. 以前我只需将my
/mnt/c
挂载到/c
即sudo mount --bind /mnt/c
然后只运行docker run -t image_name:latest -v /c/Users/quantik/path/to/volume:/path/in/container
,这样可行。 However since the release of 18.03 this no longer seems to work. 然而,自18.03发布以来,这似乎不再起作用。 Furthermore, I cannot find any resources addressing this change besides this which recommends creating a
/etc/wsl.conf
file which specifies where your drives will be mounted. 此外,我不能找到解决除此之外变化的任何资源本该建议创建一个
/etc/wsl.conf
文件,其中指定了您的驱动器将被安装。 This however does not seem to work. 然而,这似乎不起作用。 I was wondering if anyone else has encountered this issue?
我想知道是否有其他人遇到过这个问题?
I get the following error message: 我收到以下错误消息:
ERROR: for frontend Cannot start service frontend: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"rootfs_linux.go:58: mounting \\\"/c/Users/quantik/app/nginx.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/8f0733bfec60fc92405b829f5f68463ffe4e94e678651b6ab34f18b24e66a713/merged\\\" at \\\"/var/lib/docker/overlay2/8f0733bfec60fc92405b829f5f68463ffe4e94e678651b6ab34f18b24e66a713/merged/etc/nginx/nginx.conf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type ERROR: Encountered errors while bringing up the project.
I'm not sure it will help you but maybe try this: 我不确定它会对你有所帮助,但也许可以试试这个:
docker run -it -v /c/code/bitbucket/my-api:/var/my-api -w "/var/my-api" centos:7
docker run -it -v c:/code/bitbucket/my-api:/var/my-api -w "/var/my-api" centos:7
docker run -it -v c:\code\bitbucket\my-api:/var/my-api -w "/var/my-api" centos:7
For a generic version that will work anywhere 对于可在任何地方使用的通用版本
docker run -it -v $(pwd | sed 's/^\\/mnt//'):/var/api -w "/var/api" centos:7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.