Install Docker on Ubuntu 16.04 to run apps in containers

In this post, I will show you how to install Docker on Ubuntu Server 16.04 to enable apps in containers. Confused or don’t know what I am talking about? Please read my previous post on what is docker and how it compares to Virtual Machines. In short, Docker is a new way of running applications on your server by using less resources than a standard setup. It allows users to install applications inside Docker containers and run them effortlessly, isolated from the OS. The isolation helps destroy and create app containers in minutes without affecting the base OS. Due to this containerization has been increasing in popularity. Without further ado, let us see how to easily install Docker on Ubuntu 16.04 variants, including Server edition.

Install Docker on Ubuntu

It takes only a few simple steps to setup Docker on Ubuntu: add sources, install prerequisites, and finally install docker engine. In this Ubuntu Docker installation guide, I have broken this down to smaller steps to help you. Ready to roll? Open your commandline terminal and proceed.

Before you begin, enable Intel VT-x hardware virtualization in BIOS or UEFI firmware. This is required for Docker to run.

1. Update Sources and Install Docker Pre-requisites

To setup Docker on Ubuntu, run the following commands in sequence to update package information, install appropriate CA certificates, and install pre-requisites. For Ubuntu 16.04 we will install the linux-image-extra-* kernel packages as well.

2. Add Docker Source

Next, to download and install Docker on Ubuntu Linux, you need to add Docker repository and a key to access it. Add the GPG key using the following command:

Then, add the Docker repository for Ubuntu 16.04:

3. Setup Docker on Ubuntu

Now you are ready for Ubuntu Docker installation. First, update APT package index:

Next, verify if APT is connecting to the correct Docker repository:

You should see an output like what is shown below:

APT Policy results if using the correct repo.

Finally, install Docker on Ubuntu using the following command:

4. Start and Verify Docker

Now that docker installation on Ubuntu is complete, start it using the following command:

Finally, verify if Docker is installed correctly by running the following command:

You should see an output like what is shown below:

Confirmation that Docker is installed correctly.

5. Configure Docker to start on boot

Docker does not automatically start during booting on Ubuntu. Ubuntu uses systemctl to autostart services. In order to configure Docker to autostart on boot, run the following command:

After running the command, Docker will start automatically after each system reboot.