How to install and configure docker on Debian 11

In this guide we are going to learn how to install docker on Debian 11 (Bullseye).

Docker is an open source containerization platform. It enables developers to package applications into containers—standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment.

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. 

Check these links also:

# Prerequisites

To follow along, ensure you have:

  • An up to date Debian 11 system
  • Internet access from the system
  • Root access or user with sudo access
  • Knowledge of Linux terminal

# Table of Content

  1. Ensure your system packages are up to date
  2. Uninstall previous versions if any
  3. Install docker engine using the repository
  4. Install docker engine from a package
  5. Install using the convenience script
  6. Verify installation
  7. Executing the Docker Command Without Sudo
  8. Uninstalling docker when it’s longer needed

# 1. Ensure your system packages are up to date

Before proceeding, let us ensure your packages are updated

sudo apt update
sudo apt upgrade -y

# 2. Uninstall previous versions if any

Packages providing older versions of Docker are, or docker-engine.
Let us use this command to ensure that these packages do not exist in our system:

sudo apt-get remove docker docker-engine containerd runc

It’s OK if apt-get reports that none of these packages are installed.

# Installing docker

You can install Docker Engine in different ways, depending on your needs:

  • You can set up docker repositories and install docker using apt
  • You can download the DEB packages and install manually
  • You can choose to use automated convenience scripts to install Docker

# 3. Install docker engine using the repository

On a new host, the docker repositories do not exist. For the first time on a new host machine, you need to set up the Docker repository. Afterwards, you can install and update Docker from the repository.

Let us install the following packages to allow apt to use a repository over HTTPS:

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \

Add Docker’s official GPG key:

 curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/

Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below.

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

# Install Docker Engine

Update the apt package index since we added a new repository:

sudo apt-get update

Now let’s install the latest version of Docker Engine and containerd usi

sudo apt-get install docker-ce docker-ce-cli

# Optional: Installing a specific version

If you have requirements that nececitate a specific version, you can do so. To install a specific version:

  1. List the versions available in your repo:
$ sudo apt-cache madison docker-ce
 docker-ce | 5:20.10.9~3-0~debian-bullseye | bullseye/stable amd64 Packages
 docker-ce | 5:20.10.8~3-0~debian-bullseye | bullseye/stable amd64 Packages
 docker-ce | 5:20.10.7~3-0~debian-bullseye | bullseye/stable amd64 Packages
 docker-ce | 5:20.10.6~3-0~debian-bullseye | bullseye/stable amd64 Packages

Now you can Install a specific version using the version string from the second column, for example, <meta charset="utf-8">5:20.10.7~3-0~debian-bullseye.

sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING>


sudo apt-get install docker-ce=<span style="font-size: calc(11px + 0.2em);">5:20.10.7~3-0</span> docker-ce-cli=<span style="font-size: calc(11px + 0.2em);">5:20.10.7~3-0</span>
Once the installation is done, the Docker daemon starts automatically.

# 4. Install docker engine from a package

If you cannot use Docker’s repository to install Docker Engine, you can download the .deb file for your release and install it manually. You need to download a new file each time you want to upgrade Docker.

Go to, choose your Debian version – (Bullseye), then browse to pool/stable/, choose amd64armhf, or arm64, and download the .deb file for the Docker Engine version you want to install.

Install Docker Engine, changing the path below to the path where you downloaded the Docker package.

 sudo dpkg -i /path/to/package.deb

Once the installation is done, the Docker daemon starts automatically.

# 5. Install using the convenience script

Docker provides a convenience script at to install Docker into development environments quickly and non-interactively.

This example downloads the script from and runs it to install the latest stable release of Docker on Linux:

 curl -fsSL -o
 sudo sh

# 6. Verify installation

Upon installation, docker will run as a daemon. To check that docker is running, we use the systemctl status docker command:

$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-10-19 04:10:32 UTC; 4min 16s ago
TriggeredBy: ● docker.socket
   Main PID: 13456 (dockerd)
      Tasks: 7
     Memory: 39.0M
        CPU: 265ms
     CGroup: /system.slice/docker.service
             └─13456 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Oct 19 04:10:31 ip-10-2-40-246 dockerd[13456]: time="2021-10-19T04:10:31.789071579Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
Oct 19 04:10:31 ip-10-2-40-246 dockerd[13456]: time="2021-10-19T04:10:31.789278242Z" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/container>
Oct 19 04:10:31 ip-10-2-40-246 dockerd[13456]: time="2021-10-19T04:10:31.789447226Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Oct 19 04:10:32 ip-10-2-40-246 dockerd[13456]: time="2021-10-19T04:10:32.059851510Z" level=info msg="Loading containers: start."
Oct 19 04:10:32 ip-10-2-40-246 dockerd[13456]: time="2021-10-19T04:10:32.267528805Z" level=info msg="Default bridge (docker0) is assigned with an IP address Daemo>
Oct 19 04:10:32 ip-10-2-40-246 dockerd[13456]: time="2021-10-19T04:10:32.337295417Z" level=info msg="Loading containers: done."
Oct 19 04:10:32 ip-10-2-40-246 dockerd[13456]: time="2021-10-19T04:10:32.363462993Z" level=info msg="Docker daemon" commit=79ea9d3 graphdriver(s)=overlay2 version=20.10.9
Oct 19 04:10:32 ip-10-2-40-246 dockerd[13456]: time="2021-10-19T04:10:32.363783617Z" level=info msg="Daemon has completed initialization"

The Active: active (running) shows that docker was started successfully.

We can run a hello-world image to test that docker works as expected:

 sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

I got this output, showing that it works fine:

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:37a0b92b08d4919615c3ee023f7ddb068d12b8387475d64c622ac30f45c29c51
Status: Downloaded newer image for hello-world:latest

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

# 7. Executing the Docker Command Without Sudo

By default, the docker command can only be run the root user or by a user in the docker group, which is automatically created during Docker’s installation process. If you attempt to run the docker command without prefixing it with sudo or without being in the docker group, you’ll get an output like this:

$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied

If you want to avoid typing sudo whenever you run the docker command, add your username to the docker group:

sudo usermod -aG docker ${USER}

To apply the new group membership, log out of the server and back in, or type the following:

sudo su - ${USER}

You will be prompted to enter your user’s password to continue.

Confirm that your user is now added to the docker group by typing:

id -nG

I see this, confirming that i now belong to the docker group

$ id -nG
admin docker

Now I can do docker without sudo:
Let us test by running image.

$ docker run --rm -it --name alpine --entrypoint /bin/sh alpine:3
Unable to find image 'alpine:3' locally
3: Pulling from library/alpine
a0d0a0d46f8b: Pull complete
Digest: sha256:e1c082e3d3c45cccac829840a25941e679c25d438cc8412c2fa221cf1a824e6a
Status: Downloaded newer image for alpine:3
/ #

We have successfully installed docker in our system!

# 8. Uninstalling docker when it’s longer needed

To complately erase docker engine from the system, we need to uninstall the Docker Engine, CLI, and Containerd packages:

 sudo apt-get purge docker-ce docker-ce-cli -y

Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

 sudo rm -rf /var/lib/docker
 sudo rm -rf /var/lib/containerd

You must delete any edited configuration files manually.

# Conclusion

In this guide we managed to install docker on our Debian 11 system.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy