According to this tutorial from docker website, When you start a container it automatically shares your /Users/username
.
My current problem :
But in my school my $HOME
isn't in /Users
, and when I try to directly mount volumes on my container with something like docker run -d -P -v $HOME/site:/usr/share/nginx/html --name mysite nginx
(like the tutorial from the link), I can't change files through the mounted volume. So I guess my $HOME
isn't automatically shared.
But if I run docker instpect mysite
I get :
"HostConfig": {
"Binds": [
"/nfs/zfs-student-3/users/vmonteco/site:/usr/share/nginx/html"
],
and
"Mounts": [
{
"Source": "/nfs/zfs-student-3/users/vmonteco/site",
"Destination": "/usr/share/nginx/html",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
My question is simply this :
How could I manually share directories with the VM hosting docker (virtualbox here) to use it as volume mounting points?
This is how I did it with Boot2docker before it was deprecated :
With boot2docker I could have run something like :
SHAREDIR=$HOME/share
# creating share folder.
mkdir $SHAREDIR
# mount shared folder while relaunching boot2docker :
boot2docker --vbox-share="$SHAREDIR=share" up
echo "Creating and mounting \"share\" directory in boot2docker VM."
boot2docker ssh "sudo mkdir /share; sudo mount -t vboxsf share /share"
# running the container :
docker run -ti --rm -v /share:/share -v /Users:/Users base/archlinux sh
And it worked fine.
But now boot2docker is deprecated and I didn't find how to do this with the VM I have to use now (it uses virtualbox).
If I understand well, it should work the same way as boot2docker worked :
1 2
[directory from OSX] <===> [VM directory (the VM replaces Boot2docker)] <===> [container directory]
If I still understand well the only that doesn't work now is the point [1], this was handled by the middle part of the little script I just shared with boot2docker.
But how could I do now?