Install Docker on Ubuntu and Debian

In this tutorial, I will walk you through how to install Docker and Docker Compose on Ubuntu and Debian.

Installation of Docker and docker-compose from the official repositories

Docker and docker-compose are part of the official repositories of both distributions (Ubuntu and Debian), so just run the two commands below:

Installing Docker:

sudo apt install docker.io

Installing docker-compose:

sudo apt install docker-compose

The problem as often with official repositories is the update time to the latest versions which can be long, so I will explain how to install Docker and docker-compose from the Docker repository in order to have the latest version .

Installing Docker and docker-compose from the Docker repository

Make sure you have your distribution up to date:

sudo apt update
sudo apt upgrade

Install prerequisites:

sudo apt-get install ca-certificates curl gnupg lsb-release -y

Add repository GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Add repository:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Update package list:

sudo apt update

Install Docker:

sudo apt-get install docker-ce docker-ce-cli containerd.io -y

The Docker containerization engine is installed.

We will now move on to installing docker-compose which is optional to use containers.

The main advantage of using docker-compose is to use configuration files to launch the containers, which allows for easier administration and configuration.

To install docker-compose, we will retrieve the file directly from the Github repository : https://github.com/docker/compose/

Download docker-compose:

sudo curl -L "https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose

Now we make the docker-compose file executable:

sudo chmod +x /usr/local/bin/docker-compose

It’s finished, Docker and docker-compose are installed.

To save time, you can use this script:


All you have to do is deploy your containers.

Here you will find several applications ready to be used with docker-compose.

If you’re new to Docker or you don’t know what it’s for, you can read this tutorial : https://rdr-it.com/en/docker-installation-and-concrete-use-on-ubuntu/

You will also find various docker tutorials on RDR-IT.




Leave a Comment