How to install Docker on Debian 11 Bullseye system

How to install Docker on Debian 11 Bullseye system

Introduction

[openingText]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.[/openingText]

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

Prerequisites

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

Install Docker on Debian 11 bullseye distribution 

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

Step 1:
[stepName]Uninstall or Remove old Docker packages[/stepName]

[step]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]

Step 2:
[stepName]Install HTTPS supportive packages[/stepName]

[step]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

[stepImage]screenshot of code in terminal[/stepImage][/step]

Step 3:
[stepName]Import Docker’s repository GPG key[/stepName]

[step]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

[stepImage]screenshot of code in terminal[/stepImage][/step]

Step 4:
[stepName]Add Docker’s repository[/stepName]

[step]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

[stepImage]screenshot of code in terminal[/stepImage]

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

$ sudo apt update

[stepImage]screenshot of code in terminal[/stepImage]

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

Step 5:
[stepName]Install Docker CE on Debian 11 system[/stepName]

[step]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

[stepImage]screenshot of code in terminal[/stepImage][/step]

Step 6:
[stepName]Check installed Docker version[/stepName]

[step]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:

[stepImage]screenshot of code in terminal[/stepImage][/step]

Step 7:
[stepName]Verify Docker’s installation[/stepName]

[step]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:

[stepImage]screenshot of code in terminal[/stepImage]

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.

[stepImage]screenshot of code in terminal[/stepImage][/step]

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 Examine And Repair A Database in PhpMyAdmin

Over the period of time, database can be corrupted and needs to repaired. This t
less than a minute
Elizabeth Grom
Elizabeth Grom
Hosting Expert

How To Find and Install A New Theme in Drupal 8

This tutorial will help you replace the default Drupal theme with your preferred
less than a minute
Elizabeth Grom
Elizabeth Grom
Hosting Expert

How To Create Views in Drupal 8

This tutorial is compiled to help you create a view in your Drupal 8 platform.
less than a minute
Elizabeth Grom
Elizabeth Grom
Hosting Expert

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, usernam
less than a minute
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert
Click to go to the top of the page
Go To Top
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.