What's the best way to share files from Windows to Boot2docker VM?

前端 未结 5 1562
深忆病人
深忆病人 2020-12-02 08:51

I have make my code ready on Windows, but I find it\'s not easy to share to boot2docker.

I also find that boot2docker can\'t persistent my changes. For example, I cr

5条回答
  •  Happy的楠姐
    2020-12-02 09:05

    Using Docker Toolbox, the shared directory can only be /c/User:

    Invalid directory. Volume directories must be under your Users directory

    Enter image description here

    Step1&Step2 Command in the "Docker Quickstart Terminal" in the implementation of Step1 & Step2 can be:

    # Step 1. VirtualBox. Add the error in the command line, in the VirtualBox image interface manually add, as shown above.
    "C:/Program Files/Oracle/VirtualBox/VBoxManage.exe" sharedfolder add default --name "E_DRIVE" --hostpath "e:\\" --automount
    
    # Try 1. Only a temporary effect. Restart VM after sharing failure.
    #docker-machine ssh default "sudo mkdir -p /e" # Create a directory identifier, consistent with the Windows drive letter
    #docker-machine ssh default "sudo mount -t vboxsf -o uid=1000,gid=50 E_DRIVE /e"
    
    # Try 2. Modify /etc/fstab. Do not use the permanent mount. Each restart /etc/fstab content will be reset
    #docker-machine ssh default "sudo sed -i '$ a\E_DRIVE /e vboxsf uid=1000,gid=50 0 0' /etc/fstab"
    
    # Step 2. `C:\Program Files\Docker Toolbox\start.sh` https://github.com/docker/machine/issues/1814#issuecomment-239957893
    docker-machine ssh default "cat <

    Then restart the VM. Try this: docker run --name php-fpm --rm -it -v /e:/var/www/html php:7.1.4-fpm /bin/bash

    References:

    • What's the best way to share files from Windows to Boot2docker VM?
    • http://hessian.cn/p/1502.html
    • Windows + Boot2Docker, How to add D:\ drive to be accessible from within docker?

提交回复
热议问题