02
Feb

An easy way to mount a local directory in a Docker container via Boot2Docker

Comments Off on An easy way to mount a local directory in a Docker container via Boot2Docker

Problem:

On an OSX the docker process runs in the VirtualBox VM causing all mounts to be created inside that VM and not on a local host.

So starting a docker container with a mounting option

docker run -v /tmp/folder:/usr/local/my-data ...

means that the /tmp/folder within the VM is mounted to the docker container and not the folder on the local computer.

Solution:

VirtualBox Guest Additions – The ${HOME} on the local machine is automatically mounted on the VM running docker, keeping the same path: /Users/<user>/…

This means we can create a folder inside the home dir and mount it to the docker container, via the Boot2Docker VM. My script looks like:

mkdir -p ~/tmp/my-data
docker run --volume=${HOME}/tmp/my-data:/usr/local/my-data ...

No Comments

No comments yet.

Sorry, the comment form is closed at this time.

Comments RSS Feed