Install Latest Docker on Debian 10 (Buster)

I prefer to install docker on Debian due to the stability of all the packages in the OS plus it has only the stuff you need (compared to Ubuntu). But unfortunately that means you will also get an outdated version of docker engine. Here is how to install the latest version of docker in Debian.

First of all you should be installing docker using a non-root user, installing stuff using a root account opens another can of worms in the form of security issues. But if you still want to install using the root account, get rid of the sudo keyword in the following commands. I will be assuming that you are using a non root account.

Lets get the repository up to date

sudo apt update && sudo apt upgrade -y

Now lets install some per-requisites

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

Let’s add the docker repository key which will be used in the next step

curl -fsSL | sudo apt-key add -

Now we can add the repository

Please note the arch, this is for amd64. If you are installing in raspberry pi or any other architecture, you need to change this. Also make note of the URL, you need to change this if you are installing on any other Debian variants.

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

Now that the repository is added to the software sources list, lets update the packages.

sudo apt update

Lets make sure that docker will be installed from the docker repository we added earlier, and not from any built in repositories.

sudo apt-cache policy docker-ce

You should get an output like the following

    Installed: (none)
    Candidate: 5:18.09.7~3-0~debian-buster
    Version table:
        5:18.09.7~3-0~debian-buster 500
        500 buster/stable amd64 Packages

Now lets install docker

sudo apt install docker-ce

Lets check if docker is active.

sudo systemctl status docker

You should get an output similar to this.

docker.service - Docker Application Container Engine
    Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
    Active: active (running) since Tue 2021-04-27 22:08:46 AEST; 3 days ago
    Main PID: 345 (dockerd)
    Tasks: 116
    Memory: 2.0G

Once this is done, you are good to go.

But for convenience sake, I like to do the following extra steps.


Install docker-compose, because it makes spinning up containers and stacks so much easier.

sudo apt install docker-compose

Add your current account to the docker group, so that every time you run any docker commands, you don’t have to use sudo.

sudo usermod -aG docker ${USER}

Check if the current user is added to the docker group.

id -nG

It should display “docker” plus other groups the user is part of. If it does not show do a reboot.