Errors Installing Docker on an Ubuntu/Trusty64 Vagrant VM

[This blog post was originally written by Triet Le]

First, some background context…

Docker is a very convenient way to package your binaries and dependencies into an isolated consistent deployable unit. At the moment of this writing, it’s the de facto method for deploying everything from our internal services to our third-party log collectors at Pivot Freight. As mentioned in previous blogs, we are also fans of Vagrant and are using it as our main local development environment. Naturally (whether it’s is the best method or not is up to debate and feel free to comment!), we are setting up a Vagrant VM with Docker to build, test and deploy our Docker images and containers.

DockerAs part of this exercise, we ran into a strange error that seems to be a combination of Vagrant file system setup and how Docker is installed. First, let’s start with the basic set up and how we got the error:

  1. Start with an empty Vagrant Ubuntu image, e.g. vagrant init Ubuntu/Trusty64
  2. You may want to increase the memory allocated to this VM by adding this to your Vagrantfile
    config.vm.provider "virtualbox" do |vb|
    # Customize the amount of memory on the VM:
    vb.memory = "2048"
  3. Vagrant up and Vagrant SSH to the image (more details on Vagrant setup)
  4. Install Docker
    1. sudo apt-get update
    2. wget -qO- | sh
    3. sudo usermod -a -G docker vagrant (this is optional, but it sudo-ing everything was tedious)
  5. Exit the vm
  6. When I execute a vagrant reload, this happens:
[~/vagrant/ubuntu/confluent_sandbox] $ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> default: have version '14.04'. The latest is version '20150911.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address:
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /Users/tle/vagrant/ubuntu/confluent_sandbox
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant
The error output from the last command was:
stdin: is not a tty
/sbin/mount.vboxsf: mounting failed with the error: No such device

The Google Gods told me the Docker installation would update the kernel version in my Ubuntu/Trusty64. This caused some confusion with the original VBox Guest Additions that came with the VM. The default mapping of /vagrant now blew up during a Vagrant reload. I’m not an Ubuntu kernel expert so I’m not entirely sure if this is just an Ubuntu/trusty64 issue or this only happens with Docker installations.

The silver bullet…

From your host machine, run:

vagrant plugin install vagrant-vbguest

And vagrant ssh back into your guest vm and run

sudo apt-get install linux-headers-$(uname -r)

Note: there are a few posts out there suggesting to install virtualbox-guest-x11 on the guest as well. I didn’t need to do this during my set up.)

Exit and do a Vagrant reload. You should be back in the game.

Olivier Modica Portrait
About the Author

Olivier Modica

Olivier has over 15 years of proven track record in turning software developers into high performance teams, successfully running revenue-generating SaaS software, and delivering cutting-edge products on time and with high quality. Prior to Pivot Freight Olivier worked at Vast as VP of Engineering where he led engineering, operations and security across all geographies and all product lines. Before Vast, Olivier held technical leadership roles at IBM, Lombardi (acquired by IBM) and Intalio. Olivier Modica on LinkedIn