Skip to content

Instantly share code, notes, and snippets.

@luebken
Last active August 29, 2015 14:02
Show Gist options
  • Save luebken/4c1263369feda20af35b to your computer and use it in GitHub Desktop.
Save luebken/4c1263369feda20af35b to your computer and use it in GitHub Desktop.
TL;DR version for using Docker volumes on the Mac

Important notes

TL;DR: How to use Docker volumes on the Mac

Install latest version of boot2docker:

$ boot2docker delete ; boot2docker download ; boot2docker up

Download the boot2docker.iso with virtual box additions: boot2docker-v1.0.1-virtualbox-guest-additions-v4.3.12.iso:

$ wget http://static.dockerfiles.io/boot2docker-v1.0.1-virtualbox-guest-additions-v4.3.12.iso

Replace the old one at ~/.boot2docker/boot2docker.iso:

$ boot2docker stop
$ mv ~/.boot2docker/boot2docker.iso ~/.boot2docker/boot2docker.iso.backup
$ mv boot2docker-v1.0.1-virtualbox-guest-additions-v4.3.12.iso ~/.boot2docker/boot2docker.iso
$ boot2docker init

Let VirtualBox know, which path you want to mount:

$ VBoxManage sharedfolder add boot2docker-vm -name home -hostpath /Users --automount

Verify that the VM has mounted the /Users folder:

$ boot2docker up
$ boot2docker ssh "ls /Users"
Shared
mdl

Now you can mount any files from /Users into your Docker containers:

$ docker run -i -t -v /Users/mattes/project1:/data/project1 ubuntu /bin/bash

Don't forget to enable port forwarding for the appropriate ports:

VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port3000,tcp,,3000,,3000";
@jayd3e
Copy link

jayd3e commented Jun 27, 2014

Awesome, thank you so much for writing this. I have perused that thread twice now, and attempted to put it into action to no avail.

@jayd3e
Copy link

jayd3e commented Jun 27, 2014

Is boot2docker really slow for you after doing this? I just did a docker pull and it's taking an eternity.

@luebken
Copy link
Author

luebken commented Jul 1, 2014

@jayd3e Mine works fine. What is slow? A docker pull pulls images? How fast is a docker version

@luebken
Copy link
Author

luebken commented Jul 1, 2014

@rombald: thanks. included it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment