How to install Docker on Debian 11 Bullseye system

Introduction

Docker is an open-source containerized application or platform that facilitate developers to create and run software applications in an isolated container environment. These Docker containers are separated from each other and contains their own software, bundle of OS libraries, and configuration files. The Docker containers can also communicate with each other using some specified channels. The key feature of using Docker is that it enables programmers and developers to easily pack, ship, and execute any application as a self-sufficient container, portable, and lightweight, which the user can access and virtually run from any location.

We will explain some key steps in this guide for the installation of Docker on Debian 11 bullseye distribution.

Prerequisites

Users must have administrative privileges or log in as a root account on the Debian 11 system.

Install Docker on Debian 11 bullseye distribution 

The docker installation on Debian 11 bullseye system completes into the following steps:

Step 1:
Uninstall or Remove old Docker packages

If the old docker version is installed on your Debian system then, first uninstall the old version docker packages that were installed with the name of docker, docker.io, or docker-engine. To uninstall these old docker packages, execute the following command:

$ sudo apt remove –y docker docker-engine docker.io containerd runc

However, while you uninstall the old docker version packages, the directory  ‘/var/lib/docker/’ which contains docker containers, images, volumes, and networks will not be removed from your system.

Step 2:
Install HTTPS supportive packages

Update the Debian 11 packages index and install all required packages that allow ‘apt’ to use the repository over HTTPS. To install supportive packages, run the below-mentioned command in the terminal window with administrative root or ‘sudo’ privileges:

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

screenshot of code in terminal

Step 3:
Import Docker’s repository GPG key

In this step, you need to add the official Docker’s GPG key to your Debian system. Execute the command to import the Docker’s GPG key on Debian 11, which is given below:

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

screenshot of code in terminal

Step 4:
Add Docker’s repository

Once the GPG key is added to your Debian system, add the official docker’s repository to the Debian 11 distribution by running the following command:

$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list

screenshot of code in terminal

Refresh the packages index after adding the docker’s repository.

$ sudo apt update

screenshot of code in terminal

Once the repository is refreshed, you can install docker ce on Debian 11 bullseye distribution.

Step 5:
Install Docker CE on Debian 11 system

Once the repository of Docker is activated on your Debian 11 system, start the Docker installation by executing the below-given command:

$ sudo apt install –y docker-ce docker-ce-cli containerd.io

screenshot of code in terminal

Step 6:
Check installed Docker version

Once the installation is completed, check the installed docker version for verifying the installation process:

$ docker -v

The installed docker version should display in the output result as follows:

screenshot of code in terminal

Step 7:
Verify Docker’s installation

After installing the Docker engine, its services automatically start running on your system. So, check the docker service active status by using the following command:

$ sudo systemctl status docker

If the docker service is running properly on your Debian system, the following output generates on the terminal screen:

screenshot of code in terminal

Next, you need to test the Docker installation on the Debian 11 system. So, run the hello-world test container by running the following command:

$ sudo docker run hello-world

The following output shows on the terminal that verifies you have successfully installed the docker ce platform on Debian 11 bullseye distribution.

screenshot of code in terminal

Grant permissions to non-root users to run Docker commands

The non-root users by default do not have enough access to run the Docker commands. As we know, Docker uses the UNIX sockets recognized by the root user.

$ docker run hello-world

The permission denied error would display on the screen, while you run the Docker using the above command.

To fix this problem, create a ‘docker’ group using the following command:

$ sudo groupadd docker

Now, create a user with your name. Here, we have created a user ‘sam’.

$ sudo useradd -m -s /bin/bash sam

Now, add the above user into the docker group by running the following command:

$ sudo usermod -aG docker sam

Reboot or log out from the terminal. Log in back to the terminal and type the following command without sudo privileges:

$ docker run hello-world

Uninstall or remove Docker engine from Debian 11 system

To uninstall all content of the Docker engine, Containers packages, and CLI, use the following command:

$ sudo apt-get purge docker-ce docker-ce-cli containerd.io

screenshot of code in terminal

The images, container volume, and network file configuration will not automatically remove from the above command. To uninstall all files content, use the below-given commands:

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

screenshot of code in terminal

Conclusion

We demonstrated how to install Docker-ce engine on Debian 11 bullseye distribution in this tutorial. We have implemented different steps for Docker installation. Furthermore, we also discussed how we allow non-root users to run the Docker commands. Moreover, we also explained how to uninstall Docker from the Debian 11 operating system.

  • Click this link and all your queries to best hosting will end.

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use phpMyAdmin to develop a website (without MySQL experience)

Brief description A web developer who is not well versed into coding websites f
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.