How to Install Docker on Debian 11 (Bullseye): The Easy Way

Learn how to easily install Docker on Debian 11 (Bullseye) with our detailed step-by-step guide, so get up and running in no time!

Docker is a popular open-source platform that enables developers to build, ship, and run distributed applications quickly. If you’re using Debian 11 (Bullseye) as your operating system, you might wonder how to install Docker and get started with containerization. Fortunately, the process is straightforward and doesn’t require any advanced technical skills.

In this blog post, we’ll show you the easy way to install Docker on Debian 11 (Bullseye) in just a few simple steps. Whether you’re a seasoned developer or just starting with Docker, our step-by-step guide will help you get up and running quickly.

However, if you have upgraded your system to Debian 12 (Bookworm), our guide on installing Docker is here.

Installing Docker on Debian 11 (Bullseye)

There are several ways you can install Docker on your Debian 11 system. For example, it is available in the official Debian repositories, where it can be easily installed with a single APT command. However, one disadvantage to this approach is that the version available is not always the most recent.

For this reason, I will show you how to install Docker on Debian 11 from the official Docker repository. This approach guarantees you always get the latest up-to-date version and will automatically receive all future software updates as they become available. So, let’s get started.

Step 1: Install Prerequisites

First, run the two commands below to update the package index and install the prerequisite necessary to add and use a new HTTPS repository.

sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release

Step 2: Add Docker’s Official GPG Key

Next, import the Docker GPG repository key to your Debian system. This security feature ensures that the software you’re installing is authentic.

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpgCode language: JavaScript (javascript)
Add Docker’s repo GPG key.
Add Docker’s repo GPG key.

Notice that the command produces no output.

Step 3: Add Docker Repo to Debian 11

After importing the GPG keys, we’ll add the official Docker repository to our Debian 11 system. This implies that the update package will be made available with the rest of your system’s regular updates if a new version is released.

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullCode language: PHP (php)
Add the official Docker repository to Debian 11.
Add the official Docker repository to Debian 11.

As with the previous command, its execution produces no output.

Next, refresh the package list.

sudo apt update
Update the package base.
Update the package base.

As you can see, our new Docker repository is now available and ready to be used.

Step 4: Install Docker on Debian 11 (Bullseye)

To install the latest up-to-date Docker release on Debian, run the below command.

sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginCode language: CSS (css)
Install Docker on Debian 11 (Bullseye).
Install Docker on Debian 11 (Bullseye).

This installs the following Docker components:

  • docker-ce: The Docker engine itself.
  • docker-ce-cli: A command line tool that lets you talk to the Docker daemon.
  • containerd.io: A container runtime that manages the container’s lifecycle.
  • docker-buildx-plugin: A CLI plugin that extends the Docker build with many new features.
  • docker-compose-plugin: A configuration management plugin to orchestrate the creation and management of Docker containers through compose files.

That’s all! Docker should now be installed; the service started and enabled to start automatically on boot.

In addition, you can check the Docker service status using the following:

sudo systemctl is-active docker
Check the status of the Docker service.
Check the status of the Docker service.

Step 5: Verify the Docker Installation

Now let’s check if everything with our new Docker installation works properly. For this purpose, we will run a simple application called “hello-world.”

sudo docker run hello-world
Docker successfully installed, up & running on Debian 11.
Docker successfully installed, up & running on Debian 11.

Congratulations! As we can see, everything works as expected!

Enabling Non-root Users to Run Docker Commands

So far, we have successfully installed Docker on your Debian 11 system.

However, only root and users with sudo privileges can execute Docker commands by default. In other words, if you attempt to run the docker command without prefixing it with sudo, you’ll get an error message like this:

Docker permission denied.
Docker permission denied.

So, to run Docker commands as a non-root user, you must add your user to the docker group. To do that, type in the following:

sudo usermod -aG docker ${USER}

In the above command, ${USER} is an environment variable that holds your username. To apply for the new group membership, reboot your Debian system. You will then be able to execute docker commands without having to prefix them with sudo.

Run the docker command as a regular user.
Run the docker command as a regular user.

Conclusion

Installing Docker on Debian 11 (Bullseye) is a straightforward process that can be done in just a few steps. With the help of the official Docker repository, users can easily download and install the latest version of Docker on their Debian systems.

Following the steps outlined in this article, users can have Docker up and running in no time and begin taking advantage of the many benefits this powerful containerization technology offers.

So, what are you waiting for? Start experimenting with Docker on your Debian 11 system today and see how it can revolutionize how you build and deploy applications.

To learn more about Docker, check out the official Docker documentation.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%

2 Comments

  1. after running the curl, I got the following error:

    gpg: can’t create ‘/etc/apt/keyrings/docker.gpg’: No such file or directory
    gpg: no valid OpenPGP data found.
    gpg: dearmoring failed: No such file or directory
    (23) Failed writing body

    • Hi Gab,

      Judging by the message, the “/etc/apt/keyrings/” directory doesn’t exist on your Debian system. So for that, create it before running the curl command:
      sudo mkdir /etc/apt/keyrings/

      Best,
      Bobby

Leave a Reply

Your email address will not be published. Required fields are marked *