Thursday, 9 July 2015

Docker up and running (on Ubuntu*)?

Do you ever have one of those days where it feels like you’ve wasted hours trying to get something to work that should be easy and it turns out you were just missing one vital piece of information and Google was holding out on you? You do? Me too! I had one of those days today.

I’m currently reading ‘Docker Up & Running’ by Karl Matthias and Sean P. Kane. So far it’s fantastic and I’m hoping the rest of the book is as good. As with most introductory books it has instructions on how to install it’s subject, in this case Docker, on a few different platforms including Ubuntu. In fact the basic install is just three commands:

sudo apt-get update
sudo apt-get install
sudo ln -sf /usr/bin/ /usr/local/bin/docker

The book then goes on to describe how to test Docker sing a Dockerfile and project which can be cloned from a Github repository. This is where everything fell apart for me. It didn’t just work out of the box. I even enlisted the help of my very good friend Dom Davis, who eventually helped me identify that I had an old version of Docker! In fact it looked like I didn’t have Docker at all, I had We then spent what felt like a very long time trying to uninstall and install Docker using:

sudo apt-get update
sudo apt-get install docker

But we kept getting a message that Docker was already installed, but trying to run Docker gave us the message that it wasn’t installed and that we should install it with the command above. We were stumped and in the end I had to let Dom get back to what he was doing and I soldiered on. Eventually I stumbled upon this Stackoverflow post,  which explained that Ubuntu has another package called Docker and therefore you must install! But of course the package build for Ubuntu is an old version of Docker. Luckily the post also described how install the latest version of

sudo sh -c "echo deb docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker

And suddenly everything started working as expected, including the example from the book. I know they can’t cover everything, but it would have been great and saved me hours if the book had just mentioned this and instructions for installing the latest version of Docker had been included.

Hopefully this blog post will be easier to find than the Stackoverflow post and help others with Ubuntu install the right version of Docker.

* Actually I use Linux Mint, which is basically a nicer Ubuntu.

No comments:

Post a Comment