Guide: 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.
Must Read: Ultimate Smart Home Media Server with Docker and Ubuntu 18.04 – Basic

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.

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual

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:

sudo apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

Then, add the Docker repository for Ubuntu 16.04:

echo deb ubuntu-xenial main | sudo tee /etc/apt/sources.list.d/docker.list
Recommended HTPC / Home Server Builds:

3. Setup Docker on Ubuntu

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

sudo apt-get update

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

apt-cache policy docker-engine

You should see an output like what is shown below:

Install Docker On Ubuntu - Apt Policy Results
Apt Policy Results If Using The Correct Repository

Finally, install Docker on Ubuntu using the following command:

sudo apt-get install docker-engine
Recommended Guides on Docker:

4. Start and Verify Docker

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

sudo service docker start

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

sudo docker run hello-world

You should see an output like what is shown below:

Setup Docker On Ubuntu - Docker Running Correctly
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:

sudo systemctl enable docker

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

Docker is installed successfully. What to do next?

If everything went well, you should have Docker installed on Ubuntu, the service should be running and waiting to host containers with various apps. In the upcoming guides, we will show you how to install docker containers with apps (SickRage, Sonarr, CouchPotato, Plex, etc.) to build your home server on docker engine. This will enable you to install and manage home server software efficiently. Sounds exciting? Go ahead, install Docker on Ubuntu and get ready for the ride.

Did this post help you?
SmartHomeBeginner brings in-depth tutorials easy enough to understand even for beginners. If you are reading this, please consider buying us a coffee (or two) as a token of appreciation.