Install Docker via a Vagrantfile

Tons of ways of doing this on the internet – many that don’t work for various reasons – e.g. older versions of Ubuntu, etc… – and ranging from complex to very complex.

Here’s two simple ways:

  1. Most simple

Paste into a Vagrantfile:

2. A little more manual using Docker’s convenience script:

Paste into a Vagrantfile:


Here’s what didn’t work for me:

I guess it doesn’t help that precise64 is quite an old version of Ubuntu but it’s what was given on the Vagrant website for provisioning Docker.


which I basically ignored ‘cos it didn’t have a correct concrete example as of the time of writing this blog post (even though it’s Hashicorp’s own website!).

Vagrant: Provisioning

Provisioning a VM with your Vagrantfile.

e.g. to install dockercreate a file :

It’s a little convoluted. Why didn’t I use config.vm.provision "docker"? ‘cos it didn’t work for me:

Note: don’t use apt-get install -y docker as this installs the System tray! and

and add it to your Vagrantfile, e.g.:

and force Vagrant to reprovision with:

vagrant reload --provision