How to Install Docker on Debian 12


Docker is one of the most essential tools in the current era of software development for application deployment and management. This tool allows users to package their applications and run them in an isolated environment, also famous as a “container”. You can install and use it on several platforms, including Windows, macOS, and Linux distributions, e.g., Debian.

This tutorial will explore all the possible ways to install Docker in Debian 12.

Installation of Docker on Debian 12

Official Docker Repository

Deb Package File

Snap Store

Docker Shell Script

Management of Docker Service on Debian 12

Configuration Docker as a Non-root User on Debian 12

Uninstallation Docker on Debian 12

Conclusion

Let’s start with the guide.

Installation of Docker on Debian 12

When installing Docker on a Debian 12 system, it can be done from the official Docker repository, Snap Store, deb files, or using a Docker shell script. Let’s start the installation:

Method 1: Using the Official Docker Repository

This method downloads and installs the latest version of Docker through the package manager whenever the official repository releases it. It ensures that the Docker packages are retrieved with the recent modifications.

Let’s install Docker on your system from the official repository:

Step 1: Install the Necessary Packages

First, install the system dependencies that are required for the Docker installation on your Debian 12 system:

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

A screenshot of a computer

AI-generated content may be incorrect.

Step 2: Add GPG Key

Next, add the GPG key for Docker, which assures the Docker packages file’s integrity:

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

A close up of a sign

AI-generated content may be incorrect.

Step 3: Import Docker Repository

After that, import the repository to your Debian 12 system:

echo “deb [arch=$(dpkg –print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 4: Refresh Repository Packages

Now, update the repository packages to implement new changes:

A screenshot of a computer

AI-generated content may be incorrect.

Step 5: Install Docker on Debian 12 System

Now, you should be ready to install the required last version of Docker packages such as ‘docker-ce‘ (which is the community edition of the engine), ‘docker-ce-cli‘ (command line interface to Docker), and ‘containerd.io‘ (which is the runtime):

sudo apt install docker-ce docker-ce-cli containerd.io

A screenshot of a computer

AI-generated content may be incorrect.

Step 6: Check Version

You may now check the version of Docker to confirm that the respective installation has been done on the system:

As can be seen, the most recent version of Docker has now been installed.

Method 2: Using the Deb Package File

If users require the specific version, they can download the .deb package file directly from Docker’s official website. Let’s explore the steps using the deb package file.

Step 1: Download Docker Package Files on Debian 12

The initial step is downloading the Docker package files from the official site on the system. Here, the three required files are being downloaded, which are containerd.io, docker-ce, and docker-ce-cli.

Using wget, the following commands will allow you to download containerd.io, docker-ce, and docker-ce-cli.

For “containerd.io”:

wget https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/containerd.io_1.7.27-1_amd64.deb

A screenshot of a computer

AI-generated content may be incorrect.

For “docker-ce”:

wget
https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-ce_28.0.4-1~debian.12~bookworm_amd64.deb

A screenshot of a computer program

AI-generated content may be incorrect.

For “docker-ce-cli”:

wget

https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-ce-cli_28.0.4-1~debian.12~bookworm_amd64.deb

A screenshot of a computer program

AI-generated content may be incorrect.

Alternatively, you can download the required files by accessing The Official Docker Website and clicking on the hyperlinks directly:

A screenshot of a computer

AI-generated content may be incorrect.

Step 2: Install Docker

Now, install Docker on the Debian system through the following lines:

sudo apt install ./containerd.io_1.7.27-1_amd64.deb ./docker-ce_28.0.4-1~debian.12~bookworm_amd64.deb ./docker-ce-cli_28.0.4-1~debian.12~bookworm_amd64.deb

A screenshot of a computer program

AI-generated content may be incorrect.

Step 3: Verify Installation

In the last step, confirm that the system has the latest installed version of Docker:

Method 3: Using the Snap Store

Users can install the Snap Docker package from the Snap Store easily using the Snap package manager on Debian 12 systems. Let’s install Docker on Debian 12 via the Snap Store.

Step 1: Install and Enable Snap

Debian 12 has no support for Snap by default. This means you need to enable support before you can install Snap packages like Docker. Click on the link to see how to install Snap support.

Step 2: Install Docker on Debian 12

Now, execute the command below to install the Docker Snap package on your Debian 12 system:

A red arrow pointing to a black and white text

AI-generated content may be incorrect.

Method 4: Using Docker Shell Script

Using the Docker shell script is the most direct and simplest method of installing Docker on Debian 12. The reason for this is that Docker provides a script that automatically installs Docker.

Follow the instructions below to install Docker using a shell script on Debian 12.

Step 1: Download the Shell Script on Debian 12

First, use the curl command to download the Docker shell script:

curl -fsSL https://get.docker.com -o get-docker.sh

Step 2: Install Docker on Debian 12

Now, to install Docker on Debian 12, just run the following command to execute the get-docker.sh script:

A screenshot of a computer

AI-generated content may be incorrect.

You can note that the most recent version of Docker has been installed using this shell script.

Management of Docker Service on Debian 12

After installing Docker on your Debian 12 device, you may want to control the service and manage the Docker Daemon along with its containers. Managing services in Docker includes controlling the starting, enabling, disabling, stopping, and restarting Docker services.

This is how you can manage your Docker (daemon) services:

Start Docker Service

After installing Docker, the service is not started automatically; you are free to control it using the command below:

sudo systemctl start docker

Enable Docker Service

To configure the Docker daemon/service to automatically run at system boot, utilize the following command:

sudo systemctl enable docker

A close-up of a computer

AI-generated content may be incorrect.

Disable Docker Service

To disable the service from starting automatically on bootup, one can issue the command below:

sudo systemctl disable docker

A close-up of a computer screen

AI-generated content may be incorrect.

Stop Docker Service

In case you want to stop the service completely on your machine, you can simply run:

sudo systemctl stop docker

Restart Docker Service

In case you desire to refresh or start the service, execute the below line:

sudo systemctl restart docker

Display Status of Docker Service

To authenticate the services of Docker, use the following command:

sudo systemctl status docker

A screenshot of a computer

AI-generated content may be incorrect.

The output shows information about the Docker service.

Configuration of Docker as a Non-root User on Debian 12

Typically, on Debian-based systems, Docker is configured to run with root privileges after installation. Hence, using Docker commands without “sudo” gives permission errors as shown below:

A close-up of a computer code

AI-generated content may be incorrect.

To fix this error/issue on Debian 12, it is recommended to follow the given instructions to run Docker as a non-root user.

Step 1: Create a Docker group

Now we have to create a new docker group:

This has already created the new Docker group named “docker”:

Step 2: Add User to Docker Group

Then, add the current (or new/existing) user to the “docker” group on the operating system:

sudo usermod -aG docker $USER

Step 3: Restart the Debian 12 System

To apply the configurations, you need to reboot/restart the system:

Step 4: Verification

To validate the above steps, you need to provide sudo access to the chosen non-root user and check if the user can execute commands like docker ps. This command has no errors shown and gives no permission restrictions:

A close-up of a white background

AI-generated content may be incorrect.

It can be seen that the Docker commands are executing without “sudo” successfully.

Uninstallation Docker From Debian 12

The steps for uninstalling Docker from a Debian 12 system differ depending on the manner of installation, and hence, there are multiple methods for uninstallation.

The methods to uninstall Docker are as follows:

If Installed From Docker Repository or Shell Script

In case Docker is installed on a user’s system and is using the standard Debian repositories, or through the shell script, it can be uninstalled with:

sudo apt autoremove docker* –purge -y

A screenshot of a computer program

AI-generated content may be incorrect.

Moreover, execute the command below to delete the additional repository linked to Docker:

sudo rm /etc/apt/sources.list.d/docker.list

A close-up of a computer screen

AI-generated content may be incorrect.

In the same manner, the GPG key associated with Docker needs to be deleted as well using the command below:

sudo rm /usr/share/keyrings/docker.gpg

If Installed From Deb Packages Files

In the case that you have installed Docker using the deb files, use the command below to delete the software from the system:

sudo apt remove docker-ce containerd.io docker-ce-cli

A screenshot of a computer error

AI-generated content may be incorrect.

If Installed From the Snap Store

If the installation occurred through the Snap Store, the procedure stated can be used:

This covers everything related to the installation and initial setup of Docker on a Debian 12 system.

Conclusion

This article has covered the various methods one can use to install, configure, manage, and uninstall Docker on Debian 12. All of these methods are efficient; however, the most preferred are the official repository of Docker and the method of using deb package files because they provide the latest version of Docker along with its new features and updates. The simplest and quickest ways are the methods using the snap or using the shell script.

Categories