Ubuntu Add Docker Repository

Install Docker GPG APT key to the system and add the official Docker repository to the apt source. Install Docker on the remote machine. Install Python Docker module via pip. Pull an image from Docker Registry. Once you are through with this guide, you will be running a defined number of containers on your remote host. Let’s begin this guide.

  • Install Docker from Official Docker Repository. Install Docker from Ubuntu Repository. The version of the Docker package available in the Ubuntu base repository is a bit older than the version available in the official repository. Install Docker from Official Docker Repository. Docker is now available in two editions, Community Edition (CE).
  • I was trying to install docker on my Ubuntu server as an initial step to set up a continuous integration server for my Python project. As I was following through the guide provided by docker, I was not able to proceed with adding the public PGP key of docker's apt repository at Ubuntu's Advanced Packaging Tool (APT) key store automatically.

This is the first in our Docker tutorial series. In this article, you’ll learn how to install the latest Docker on Ubuntu and how to configure it.

By latest Docker, I mean the latest Docker Engine Community Edition (CE). Ubuntu also has Docker packages available in their repository, however, I would advise using the community edition.

For this tutorial, I created a new Ubuntu server on Linode. You may sign up for Linode and deploy your own Linux server in less than two minutes. They even provide $60 free credits to our readers.

Installing Docker on Ubuntu

So, I presume you have an Ubuntu system installed. The first thing you should do is to update your system:

If you already have any kind of Docker package installed, you should remove them as well to avoid conflict.

Now the following steps will get you an operational version of Docker CE up and running on your system.

Step 1: Enable installation via HTTPS

You need the following packages for using apt over https:

Ubuntu Add Docker Repository

Some of the packages might already be installed on your system.

Step 2: Add the official Docker GPG key

Before you add the new repository from Docker, add its GPG key. Use the curl command to download the GPG key and then add it using apt-key command. You can combine both commands with pipe:

It’s a good idea to verify the key to avoid bad surprises:

It’s output should be like this:

Step 3: Add the Docker repository

Now that you have the repository key added, add the repository itself:

If you are using Ubuntu 16.04, you may have to update the repository as well:

Step 4: Install Docker

Everything is set. Now you should install Docker and its related packages:

Setting up Docker on Ubuntu

You have Docker installed but it’s not over just yet. You need to do some other basic setup and configuration in order to run it smoothly.

1. Run docker without sudo

One thing you should do is to add your username to docker group so that you don’t need to use sudo all the time.

The docker group may already exist. Use the groupadd command to create the group docker:

Add your username or other users to this group with usermod command. Change username with the actual user name.

2. Verify docker installation by running a sample container

First, restart Ubuntu and then confirm that Docker is running fine by downloading and running the hello-world docker image:

Add docker repository ubuntu xenial

Ubuntu Add Docker Repository To Ubuntu

It’s output should be like this:

Ubuntu Add Docker Repository

Ubuntu Add Docker Repository Download

To give you a better understanding, let me explain what happened here.

  • The Docker client contacted the Docker daemon.
  • The Docker daemon pulled the “hello-world” image from the Docker Hub.
  • The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
  • The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

3. Run Docker at each boot

Ubuntu Add Docker Repository To Computer

To make sure that Docker runs automatically on each boot, use this command:

Docker Local Repository

That’s it. You have just learned to install Docker CE on Ubuntu Linux. Stay tuned for more Docker tutorials in this series.