docker with shared folder d drive

2019-01-27 01:26发布

问题:

I'm trying to get docker to mount my d drive. Have been struggling with a lot of stack and git, and none of them seem to work for me.

I already added my d drive to the shared folder

then I mount in my docker-compose.yml

running docker-compose up works when the folder is in C drive, but not when in D drive.

I will get the error package.json not found, meaning that the D drive is not mounted.

I tried to inspect my container, and this is what I get

can see that source is the right path, but it doesn't work.

Is it something wrong with my setting, or that docker doesn't support this yet? Any workaround? like move everything to D drive?

I did tried with setting the MACHINE_STORAGE_PATH in environment, turn out didn't work and screw up everything. Must be I did something wrong.

Please help. My new laptop only have 128GB in C drive, is not possible have everything in the C drive.

Thanks in advance.

回答1:

You could check "Docker: Permanently Mount a VirtualBox Shared Folder"

Creating a shared folder in VirtualBox (which you did) is only the first step

You still need to mount it permanently in your boot2docker ssh session:

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

Add to that file:

mkdir -p /mnt/src
mount -t vboxsf -o defaults,uid=`id -u docker`,gid=`id -g docker` src /mnt/src