本文介绍了Docker撰写安装窗口文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows中使用docker工具箱,并尝试在docker-compose.yml文件中安装一个Windows文件夹,如下所示:

  nginx:
image:nginx:latest
container_name:test_server
ports:
- 80:80
volumes:
- / sss: / c / data / www:ro
环境:
- VIRTUAL_HOST = test.local

我的目标是将C:\data\www挂载到已经由docker工具箱创建的boot2docker VM映像,然后从那里到其中的nginx容器。



不幸的是,它不工作,我得到一个文件夹sss在boot2docker图像,但它的空,而不是我的Windows数据。



我做错了什么?是否有更好的做法,以便在开发过程中在Windows中使用docker(所以您需要在Windows,docker vm(boot2docker)和docker容器之间共享代码)



非常感谢



Nick

解决方案

从:



您需要:




  • 修改VirtualBox VM(确保先停止): p>

      VBoxManage共享文件夹添加<机器名/ id> --name< mount_name> --hostpath< host_dir> --automount 
    #在你的情况下
    / c / Program\ Files / Oracle / VirtualBox / VBoxManage.exe共享文件夹添加默认值--name www --hostpath'C:\data\ww' --automount


  • 添加:




    • 编辑/创建(如 root /mnt/sda1/var/lib/boot2docker/bootlocal.sh ,( sda1 可能会有所不同)

    • 添加

        mkdir -p < local_dir> 
      mount -t vboxsf -o defaults,uid =`id -u docker`,gid =`id -g docker`< mount_name> < local_dir





(您可能需要)


I am using docker toolbox in Windows and trying to mount a windows folder in a docker-compose.yml file like this:

nginx:
  image: nginx:latest
  container_name: test_server
  ports:
    - "80:80"
  volumes:
    - /sss:/c/data/www:ro
  environment:
    - VIRTUAL_HOST=test.local

My objective is to Mount C:\data\www to boot2docker VM image which is already created by docker toolbox and then from there to the nginx container inside of it.

Unfortunately its not working, i get a folder sss inside boot2docker image but its empty without targeting to my windows data.

What I am doing wrong? Is there any better practice in order to use docker in windows while you are developing (so you need to share code between windows, docker vm (boot2docker) and docker containers)

Thanks a lot,

Nick

解决方案

From "Manually sharing directory as docker volume mounting point":

You need to:

  • modify your VirtualBox VM (make sure it is stopped first):

    VBoxManage sharedfolder add <machine name/id> --name <mount_name> --hostpath <host_dir> --automount
    # in your case
    /c/Program\ Files/Oracle/VirtualBox/VBoxManage.exe sharedfolder add default --name www --hostpath 'C:\data\ww' --automount
    

  • add an automount to your boot2docker VM:

    • Edit/create (as root) /mnt/sda1/var/lib/boot2docker/bootlocal.sh, (sda1 may be different for you)
    • Add

      mkdir -p <local_dir>
      mount -t vboxsf -o defaults,uid=`id -u docker`,gid=`id -g docker` <mount_name> <local_dir
      

(you might have to add the umask as in here)

这篇关于Docker撰写安装窗口文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 15:35