Docker: Sharing a volume on Windows with Docker Toolbox

后端 未结 5 1046
囚心锁ツ
囚心锁ツ 2020-12-08 11:14

I\'m trying to setup a developer environment through a Docker container on my Windows 7 computer.

I\'ve installed Docker toolbox for Windows.

I have an

相关标签:
5条回答
  • 2020-12-08 11:19
    • Open "Oracle VM VirtualBox"
    • Once "default is selected" click on "configuration"
    • Go to "Sheared Folders" Add the desired Folder
    • Then restart default by typing in your console

      docker-machine restart default

    0 讨论(0)
  • 2020-12-08 11:20

    The message is a "WARNING" not an error message. Are you sure your container is not created ? Have you checked with the command "docker ps -a" ?

    If the message is the root cause of your problem, you should sort out the non-existence of /var/www/html/test inside your container. If it is not needed, you should removed it from apache configuration (probably inside the file /etc/apache2/sites-enabled/000-default.conf or /etc/apache2/apache2.conf).

    If /var/www/html/test is needed, you could try and add

    RUN mkdir /var/www/html/test
    

    inside your Dockerfile in order to make sure the directory exists.

    Also, in order to try debugging the problem, you might want to try running the container without using the volume. If there is no error, you should then enter the container ("docker exec -it php5.6_container bash") in order to debug the potential problem inside your container and check the structure of your container.

    0 讨论(0)
  • 2020-12-08 11:26

    See the note for Windows and Mac at https://docs.docker.com/engine/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume. Particularly:

    If you are using Docker Machine on Mac or Windows, your Docker daemon has only limited access to your OS X or Windows filesystem. Docker Machine tries to auto-share your /Users (OS X) or C:\Users (Windows) directory.

    Basically, you will need to move your site files to somewhere such as c:\Users\sites and then mount using something like suggested in documentation:

    docker run --name=php5.6_container --rm -v "/c/Users/sites:/var/www/html" -p 80:80 -p 8080:8080 php5.6
    
    0 讨论(0)
  • 2020-12-08 11:31

    I think for Docker volume options, double quotes are not required:

    docker run --name=php5.6_container --rm -v //c/sites:/var/www/html -p 80:80 -p 8080:8080 php5.6
    

    Check if it is working. I am not sure.

    See example of volume mapping at Manage data in containers.

    0 讨论(0)
  • 2020-12-08 11:37

    Step 1: C:/Program Files/Oracle/VirtualBox/VBoxManage sharedfolder add default -name $shared_folder -hostpath d:/data

    To show shared folders:

    VBoxManage showvminfo default | less
    

    Step 2(a): mount -t vboxsf -o uid=1000,gid=50 $shared_folder /data

    Step 2(b): Adding an automount to boot2docker

    While logged into the machine, edit/create (as root) /mnt/sda1/var/lib/boot2docker/bootlocal.sh by adding below block to the file, sda1 may be different for you...

    mkdir -p /data mount -t vboxsf -o uid=1000,gid=50 $shared_folder /data

    Then, docker-machine restart default

    Step 3: Adding volume when running the container(gogs as example) docker run --name=gogs -rm --net=host -d -v /fuple:/data gogs/gogs

    0 讨论(0)
提交回复
热议问题