Getting Docker Installed on Ubuntu 12.04 LTS

A few days ago I posted the blog entry “Using SSH Locally to Work With Ubuntu VM + VMware Tools Installation via Shell“, it was related to getting a clean Ubuntu Server install running with VMware Tools and so that I could use it as a hosted instance. Simply put, being able to SSH into it just as I would a hosted AWS or Windows Azure Ubuntu Server image. Once I had the default virtual machine running 12.04 LTS I went about another installation that is needed to run Docker. Docker will have issues with anything pre-3.8 kernel. Running the command below will show that kernel 3.5 is the current kernel in 12.04 LTS.

[sourcecode language=”bash”]
apt-cache search linux-headers-$(uname -r)
[/sourcecode]

To update to the 3.8 kernel I ran the following command and then rebooted.

[sourcecode language=”bash”]
sudo apt-get install linux-image-generic-lts-raring linux-headers-generic-lts-raring
sudo shutdown -r now
[/sourcecode]

With the reboot complete, I checked the kernel version again and 3.8 was installed successfully.

[sourcecode language=”bash”]
@ubuntu:~$ apt-cache search linux-headers-$(uname -r)
linux-headers-3.8.0-33-generic – Linux kernel headers for version 3.8.0 on 64 bit x86 SMP
[/sourcecode]

To get Docker installed (as of 0.6) run the following command.

[sourcecode language=”bash”]
sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\
> /etc/apt/sources.list.d/docker.list"
[/sourcecode]

Next update the sources, then install lxc-docker.

[sourcecode language=”bash”]
sudo apt-get update
sudo apt-get install lxc-docker
[/sourcecode]

To verify that docker is installed I executed the following command and…

[sourcecode language=”bash”]
sudo docker run -i -t ubuntu /bin/bash
[/sourcecode]

…see similar results just after issuing the command.

[sourcecode language=”bash”]
Unable to find image ‘ubuntu’ (tag: latest) locally
Pulling repository ubuntu
8dbd9e392a96: Download complete
b750fe79269d: Download complete
27cf78414709: Download complete
[/sourcecode]

After that displays then I typed exit to leave docker. I now have a running version of docker on the Ubuntu 12.04 LTS instance ready for testing and hacking with docker.