Share volumes in a Docker Container on MacOS - simplified
In the last post I showed how to
share a volume in a Docker container on MacOS. There was a way, but it was not
really easy.
Alternatively, there is another way that’s much easier: use
docker-machine-fs.
Step 1: Install docker-machine-nfs
Standalone:
Or using Homewbrew:
Step 2: Map the volume in VirtualBox and permanently mount the volume in boot2docker
As seen in the log, sudo is needed to create/update /etc/exports
.
Content:
Note, that in boot2docker the file /mnt/sda1/var/lib/boot2docker/bootlocal.sh
is overridden:
I.e., /Projects/hadoop
in MacOS is mapped to /Projects/hadoop
in boot2docker.
Test it:
Step 3: Map the volumes
Run the Docker container:
List the project directory in the Docker container:
It works.
Tags
docker
macos