【问题标题】:Mount a volume to a container in WSL for Docker 18.03在 Docker 18.03 的 WSL 中将卷挂载到容器
【发布时间】:2018-05-18 03:52:27
【问题描述】:

因此,自从 Docker v18.03 发布以来,我一直无法将卷挂载到 WSL 中的容器。以前我所要做的就是将我的/mnt/c 挂载到/c,即sudo mount --bind /mnt/c,然后运行docker run -t image_name:latest -v /c/Users/quantik/path/to/volume:/path/in/container,这样就可以了。但是,自从 18.03 发布以来,这似乎不再起作用。此外,除了this 建议创建一个指定驱动器安装位置的/etc/wsl.conf 文件之外,我找不到任何解决此更改的资源。然而,这似乎不起作用。我想知道是否有其他人遇到过这个问题?

我收到以下错误消息:

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.

【问题讨论】:

    标签: ubuntu docker windows-subsystem-for-linux


    【解决方案1】:

    我不确定它是否会对您有所帮助,但不妨试试这个:

    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
    

    适用于任何地方的通用版本

    docker run -it -v $(pwd | sed 's/^\/mnt//'):/var/api -w "/var/api" centos:7

    【讨论】:

      猜你喜欢
      • 2021-09-17
      • 1970-01-01
      • 2021-07-16
      • 1970-01-01
      • 2017-07-21
      • 2017-04-15
      • 2021-01-13
      • 1970-01-01
      相关资源
      最近更新 更多