Packer scripts to build a Vagrant-compatible boot2docker box.
Shell Makefile Smarty Ruby
#50 Compare This branch is 170 commits ahead, 10 commits behind mitchellh:master.
Latest commit cca1bb0 May 13, 2016 @dduportal Merge pull request #49 from dduportal/disk-size
Harddrive default size to 120 Gb. Closes #47.

boot2docker Vagrant Box

This repository contains the scripts necessary to create a Vagrant-compatible boot2docker box.

If you work solely with Docker, this box lets you keep your Vagrant workflow and work in the most minimal Docker environment possible.


The box is available on Hashicorp's Atlas, making it very easy to use it:

$ vagrant init dduportal/boot2docker
$ vagrant up

Tips & tricks

  • Vagrant synced folder has been tested with :

    • Shared Folder for Virtualbox and Parallels Desktop: This is default sharing system
    • rsync : add this line to your Vagrantfile (it will overwrite the default vboxsf sync behaviour) :

      config.vm.synced_folder ".", "/vagrant", type: "rsync"
    • NFS : For now, use environment variable to enable NFS (Mac OS and Linux tested). It will ask for your admin password.

      $ export B2D_NFS_SYNC=1
      $ vagrant up
  • Network considerations :

    • By default, we use a NAT interfaces, which have its ports 2375 and 2376 (Docker IANA ports) forwarded to the loopback (localhost) of your physical host.
    • Also, we provide a private network that allow direct-IP exchange from your host. This is less portable but easier to use. This usage come from the official docker-machine system.
    • If you face problems (Virtualbox errors, IP overlapping, etc.) with the private network, you can disable it with an environment variable :

      $ vagrant up
  • If you want to tune contents (custom profile, install tools inside the VM) that do not fit into the "vagrant provisioning" lifecycle combined with the un-persistence of boot2docker, the "bootlocal" system has been extended :

    • The boot2docker FaQ says that you can provide a custom script, named to execute things at the end of the boot.
    • We customize in order to run that script from the /vagrant share when mounted, at the end of the boot.
    • So : just place a "" script alongside your Vagrantfile to customize what's inside your b2d VM.
  • If you use the VM as a remote Docker daemon in a private networked docker server you need to add in your : (Thanks to @Freyskeyd)

# Regenerate certs for the newly created private network IP
sudo /etc/init.d/docker restart
# Copy tls certs to the vagrant share to allow host to use it
sudo cp -r /var/lib/boot2docker/tls /vagrant/

Next, you need to configure your Docker environment :

# For VirtualBox provider:
export DOCKER_CERT_PATH=`pwd`/tls
export DOCKER_HOST=tcp://

# For Parallels provider:
export DOCKER_CERT_PATH=`pwd`/tls
export DOCKER_HOST="tcp://`vagrant ssh-config | sed -n "s/[ ]*HostName[ ]*//gp"`:2376"

Building the Box

If you want to recreate the box, rather than using the binary, then you can use the scripts and Packer template within this repository to do so in seconds.

To build the box, first install the following prerequisites:

Then run this command to build the box for VirtualBox provider:

make virtualbox

or this one to build the box for Parallels provider:

make parallels