This is the first step for me from old and outdated LAMP to the new “era” in containerized applications. I decided to install Docker and use it for all my websites on a test environment at first. This article is just an introduction on how to install Docker on Ubuntu LTS and Debian Stable, which will be followed by articles showing how to install Docker in CentOS and Fedora too.

Therefore, lets start and show how to install Docker. Some of the steps described below can also be found in the Docker Book, by James Turnbull.

I will install Docker CE (Community Edition) on both Ubuntu and Debian. There is also a Docker EE (Enterprise Edition) that is supported entirely by Ubuntu on all known platforms, but on Debian, there is only the community edition supported. As my servers are running Debian at this point, I am directly interested in showing you how to install and use Docker on Debian, but I will also show you how to use it in Ubuntu too. For more information on Docker’s variants, you should consult the documentation page of the Docker project. The documentation only covers installation of the Community Edition on the following Linux distributions: Ubuntu, Debian, CentOS and Fedora. Nevertheless, Docker Enterprise Edition is also supported and delivered with SUSE Linux Enterprise and Red Hat Enterprise Linux.

Installing Docker in Ubuntu 16.04 LTS

Prerequisites: 64 bit, Kernel > 3.10

Install linux-image-extra and linux-image-extra-virtual

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

Install Docker and some extra packages

sudo apt install apt-transport-https ca-certificates software-properties-common curl

Add the official Docker GPG key

curl -fsSL | sudo apt-key add -

Add the Docker repository:

sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

Do a repository update:

sudo apt update

Install the Docker CE (Community Edition) package:

sudo apt install docker-ce

Check to see if Docker was properly installed in Ubuntu:

sudo docker info

This is it. Now you have Docker installed on your Ubuntu system.

Installing Docker on Debian 9 Stretch

Prerequisites: 64 bit, Kernle > 3.10 -> Debian 9 has Kernel 4.9 thus you will not have to deal with this issue.

Install dependencies:

sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common

Add the Docker’s official GPG key:

curl -fsSL$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -

Add the Stable Docker repository:

In order to add the Docker repository, you will need to edit the /etc/apt/sources.list file. For this, we will use the following command to add the repo:

sudo add-apt-repository "deb [arch=amd64]$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable"

Install Docker CE (Community Edition):

sudo apt update
sudo apt install docker-ce

You can test to see if Docker is working properly by using the command:

sudo docker run hello-world

The output would be:

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:

Here you have it, Docker is installed on your Debian 9 system, too!