Install Docker on Ubuntu 14.04

First update the system.

$ sudo apt-get update
$ sudo apt-get -y upgrade

Add the recommended package for the current kernel.

$ sudo apt-get install linux-image-extra-$(uname -r)

Add the official key for Docker.

$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

Add the source to the sources.list.d and refresh the packages.

$ echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
$ sudo apt-get update

Now you can install Docker.

$ sudo apt-get install docker-engine

Change the following in /etc/default/ufw:

DEFAULT_APPLICATION_POLICY="DROP" 

becomes

DEFAULT_APPLICATION_POLICY="ACCEPT" 

Restart the firewall.

$ sudo ufw reload

Create a Docker group and your current user to it to be able to connect to the Docker daemon.

$ sudo groupadd docker
$ sudo usermod -aG docker $USER

Login again to start using Docker. Now check if Docker is working.

$ sudo service docker start
$ sudo docker run hello-world

Hopefully this last step will download the image and run the container. If you are happy with the result, make it start automatically on system start.

$ sudo systemctl enable docker