gpt4 book ai didi

windows - 无法将Windows主机目录挂载到Docker容器

转载 作者:行者123 更新时间:2023-12-02 18:32:17 25 4
gpt4 key购买 nike

我在Windows 10 Pro上,使用Docker版本1.12.0-rc3-beta18(内部版本:5226)。我想将Docker用于Windows计算机上的PHP开发。我尝试了将主机目录挂载到Docker容器的所有可能的方式(我希望如此):

  • //c/Users/...
  • /c/Users/...
  • //C/用户/...
  • /c/Users/...
  • c:/用户/...
  • c:\Users ...
  • “c:\Users ...”
    两种变体都没有发射容器。是的,docker run创建了容器,我可以使用docker ps --all看到它。但是我不能开始。例如。我尝试了简单的文档示例:
  • docker run -d -P -v "C:\temp":/opt/webapp training/webapp python app.py

    docker logs e030ba0f7807
    重播为
    python: can't open file 'app.py': [Errno 2] No such file or directory
    发生了什么?

    最佳答案

    如果您将docker与docker-machine一起使用,则需要先将c:\temp注册为VirtualBox中的共享文件夹。

    参见“docker with shared folder d drive

    docker-machine ssh session 中:

    sudo touch /mnt/sda1/var/lib/boot2docker/bootlocal.sh

    添加到该文件:
    mkdir -p /mnt/temp
    mount -t vboxsf -o defaults,uid=`id -u docker`,gid=`id -g docker` temp /mnt/temp

    然后,例如可以通过 /mnt/temp访问该路径。
    C:\Users也是如此,它已经是共享文件夹 c/Users

    可通过 /c/Users访问。

    使用Hyper-V,请参阅 Running Docker on Hyper-V中的“ Henning M Stephansen”:

    Hyper-V is a more isolated and restrictive environment than VMWare or VirtualBox is, so there’s no concept of shared folders.
    However we can mount and access Windows shares from our Docker VM.

    The first thing you need to do is to share a folder. This folder can be restricted to just your user.
    If the VM has access to the network through an External Virtual Switch or an Internal Virtual Switch you should be able to mount your folder from the docker VM.



    http://www.henning.ms/wp-content/uploads/2015/05/share-internet.jpg

    To be able to mount a windows share from Boot2Docker/Tiny Core Linux we need to install some additional module (This might be included in your image):


    wget http://distro.ibiblio.org/tinycorelinux/5.x/x86/tcz/cifs-utils.tcz
    tce-load -i cifs-utils.tcz

    Now we can mount the shared folder using the following command


    sudo mount -t cifs //HOST-IP-HERE/SharedFolderPath /path/where/we/want/it/mounted -o username=HOST_USERNAME_HERE

    关于windows - 无法将Windows主机目录挂载到Docker容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38261392/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com