Docker Compose mount Windows folder

前端 未结 1 899
既然无缘
既然无缘 2020-12-09 13:17

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

nginx:
  image: nginx:latest
  container         


        
相关标签:
1条回答
  • 2020-12-09 13:42

    My objective is to Mount C:\data\www to boot2docker VM image

    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)

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