Oct 23, 2023 5 min read

How to Install Docker on Debian 11

Install docker on debian 11 with our step-by-step tutorial. It is a platform that simplifies application deployment by automating the creation.

Install Docker on Debian 11
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to install docker on debian 11 .Let’s briefly understand - What is Docker?

Docker is a popular open-source platform that allows you to automate the deployment, scaling, and management of applications using containerization. Installing Docker on Debian 11 enables you to quickly set up and run applications in isolated containers.

With the help of the containerization platform Docker, you can easily create, test, and deploy applications as portable, independent containers that can run almost anywhere.

This tutorial will help you through the process of installing Docker on Debian 11.

Advantages

  1. Containerization: Docker enables efficient and lightweight containerization, allowing applications and their dependencies to be isolated and portable across different environments.
  2. Efficient Resource Utilization: Docker optimizes resource usage by allowing multiple containers to share the same host system, reducing the need for dedicated resources for each application.
  3. Application Portability: Docker containers are highly portable, allowing you to deploy applications consistently across different platforms, reducing deployment issues and increasing flexibility.
  4. Scalability and Flexibility: Docker simplifies application scaling and deployment, enabling you to quickly spin up multiple instances of containers to handle changing workloads and demands.
  5. Reproducibility and Collaboration: Docker provides a consistent and reproducible environment for applications, making it easier for developers to collaborate and share applications with confidence.

Install Docker on Debian

To install the most recent stable version of Docker from the Docker repositories, follow these instructions.

01. Install the required packages to add a new repository over HTTPS:

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

02. Use the following curl command to import the repository's GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

The command will return OK if it is successful.

03. The stable Docker APT repository should be added to your system's list of software repositories:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

$(lsb release -cs) returns the Debian distribution name. It is buster in this case.

04. Install the most recent version of Docker CE (Community Edition) and update the apt package list:

sudo apt update
sudo apt install docker-ce

05. The Docker service will start automatically after the installation is complete. To check, type in:

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 2019-07-30 20:52:00 GMT; 1min 11s ago
    Docs: https://docs.docker.com
...

06. The most recent stable version of Docker is 19.03.1 as of this writing:

docker -v
Output
Docker version 19.03.1, build 74b1e89

Executing the Docker Command Without Sudo

By default, only root and users with sudo privileges can run Docker commands.

You must add your user to the docker group that is generated during the installation of the Docker CE package if you wish to run Docker commands without prepending sudo. You can do that by typing:

sudo usermod -aG docker $USER

Your username is stored in the environment variable $USER.

Log out and back in again to refresh the group membership.

Once finished, type the following to confirm that you can run docker commands without sudo:

docker container run hello-world

The command will download a test image, execute it within a container, print a message saying "Hello from Docker," and then exit. The output should seem as follows:

Using Docker

Now that you have Docker installed on your Debian 11 system, let us review the fundamental ideas and commands of Docker.

Docker Images

A Docker image consists of a number of filesystem levels that correspond to the instructions in the Dockerfile that make up an executable software application. An image is an immutable binary file that contains the application together with any additional dependencies, including any libraries, binaries, or instructions required for the application to function.

The majority of Docker images are accessible through Docker Hub. It is a cloud-based registry service that is used, among other features, to store Docker images in either a public or private repository.

Use the docker search command to look for an image in the Docker Hub registry. For example, to find a Debian image, you would type:

docker search debian

Docker Containers

A container is an instance of an image. For a single application, process, or service, a container represents the runtime.

Although it may not be the best analogy, if you are a programmer, you may consider a Docker image to be a class and a Docker container to be an instance of that class.

Use the docker container command to manage, start, stop, and remove containers. The following command, for instance, will launch a Docker container based on the Debian image.  If you do not have the image locally, it will be downloaded first:

docker container run debian

Due to the lack of a long-running process and the absence of any further commands, the Debian container will shut down soon after starting. The container started up, executed a blank command, and then exited.

You can interact with the container using the command line by using the switch -it. To start an interactive container type, do the following:

docker container run -it debian /bin/bash
Output
root@ee86c8c81b3b:/#

As you can see from the output above, the command prompt changes once the container is started, indicating that you are now operating from inside the container.

Use the following command to list all running Docker containers:

docker container ls

The output will be blank if no containers are currently running.

Pass the -a switch to display all containers:

docker container ls -a

Simply copy the container ID (or IDs) and paste them after the container rm command to delete one or more containers:

docker container rm c55680af670c

FAQ's on how to install Docker on Debian 11

What are the system requirements for installing Docker on Debian 11?

Docker requires a 64-bit architecture, a Debian 11 installation, and a Linux kernel version of 3.10 or higher.

Is Docker compatible with Debian 11?

 Yes, Docker is compatible with Debian 11.

How can I install Docker on Debian 11 using the package manager? 

To install Docker on Debian 11, you can use the apt package manager. Run sudo apt install docker.io to install the Docker Engine package.

Do I need to add my user to a specific group to run Docker commands?

Docker commands require root privileges or the user to be a member of the docker group. You can add your user to the group using sudo usermod -aG docker your_username.

How can I verify if Docker is installed correctly on Debian 11? 

You can check the Docker version and verify its installation by running docker version in the terminal.

How can I install Docker Compose on Debian 11? 

To install Docker Compose on Debian 11, you can use the curl command to download the binary and move it to the appropriate directory. 

Can Docker images and containers be managed using a graphical interface on Debian 11? 

Yes, there are graphical interfaces available to manage Docker images and containers, such as Portainer and Kitematic.

Conclusion

Docker installation on Debian 11 is a rather simple process. The de facto container technology standard, Docker, is a crucial tool for DevOps engineers and their continuous integration and delivery pipeline.

Visit the official Docker documentation to learn more about Docker.

If you have any suggestions or queries, kindly leave them in the comments section.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.