Docker is a fundamental tool in the current software development era to deploy and manage applications. It is a containerization technique that helps users to package and run their necessary applications within an isolated environment i.e. containers. It can be used and run on various platforms, i.e. Windows, MacOS, and Linux distributions including Debian.
This guide will illustrate all the possible approaches for Docker installation on the Debian 12 system.
Quick Outline
- How to Install Docker on Debian 12?
- How to Manage Docker Service on Debian 12?
- How to Configure Docker as a Non-root User on Debian 12?
- How to Remove Docker From Debian 12?
- Final Thoughts
How to Install Docker on Debian 12?
In the Debian 12 system, Docker can be installed from:
- Default Debian Repository
- Official Docker Repository
- Deb Package File
- Snap Store
- Docker Shell Script
Method 1: Install Docker on Debian 12 From Default Debian Repository
The default Debian repository contains a collection of software packages including Docker. It is the easiest Docker installation method but it provides the outdated version of Docker. Go through the given instructions to install Docker on your Debian 12 using this method.
Step 1: Update Debian System
Before installing Docker, make sure to update your system’s packages using the given commands:
sudo apt upgrade
This will refresh the Debian’s repository packages.
Step 2: Install Docker on Debian 12
Then, use the given command to install the Docker package i.e. “docker.io” from the official Debian repository:
Step 3: Ensure Installation
To ensure that Docker has been installed on your Debian system, check its version:
The output displays Docker’s outdated version that is installed on the system:
Method 2: Install Docker on Debian 12 From Official Docker Repository
If you want to install the most up-to-date (latest) version of Docker, you can install it from the official Docker repository. This method provides the latest Docker packages with the newest updates and features. Moreover, it also automatically fetches and installs Docker’s latest version via the package manager whenever it is available from the official repository.
Here are the steps to install Docker on your Debian 12 system from the official Docker repository:
Step 1: Install Required Dependencies
First, install the following necessary dependencies for the installation of Docker on the Debian 12 system:
Step 2: Import Docker GPG Key
Next, utilize the provided command and import the Docker GPG key to ensure the reliability of Docker packages:
Step 3: Add Docker Repository to Debian 12
Then, add/import the Docker’s official repository to the Debian 12 system:
Step 4: Refresh System’s Packages
After that, update your system to implement new changes:
Step 5: Install Docker on Debian 12 System
Now, install the essential latest Docker packages i.e. the “docker-ce” (Docker engine’s community edition), “docker-ce-cli” (a command-line interface to communicate with Docker). and “containerd.io” (container runtime) by typing out the given command:
Step 6: Verification
Finally, check out the Docker’s version to ensure its installation on your system:
It can be observed that the Docker’s latest has been successfully installed:
Method 3: Install Docker on Debian 12 From the Deb Package File
You can also get Docker’s latest version by downloading its Deb package file from the official Docker website and install manually. Follow the given steps to install Docker on Debian 12 via the Deb package file.
Step 1: Download Docker Package Files on Debian 12
First, visit the official Docker website, copy the link of the required latest Docker deb files, and download them on your system through the “wget” command. Here, we are downloading the Deb package files of “containered.io”, “docker-ce”, and “docker-ce-cli”.
For “containerd.io”:
For “docker-ce”:
For “docker-ce-cli”:
Alternatively, you can download the desired Docker deb files directly from the website by clicking on them as seen below:
Step 2: Install Docker on Debian 12
Then, install the downloaded deb package files using the following command to get Docker’s latest version on your system:
Step 3: Verify Installation
Lastly, display the Docker’s version to confirm its installation on the system:
The below output displays the latest version of Docker installed on the system:
Method 4: Install Docker on Debian 12 From the Snap Store
The Snap store also contains the Docker snap package that can be simply installed on Debian 12 through the “snap” package manager. You can install Docker on Debian 12 from the Snap Store by following the given steps.
Step 1: Install and Enable Snap
By default, the snap support is not enabled on the Debian 12 system. Thus, you have to enable it first in order to install Snap packages including Docker. Check Out This Post to see the method of installing and enabling it.
Step 2: Install Docker on Debian 12
Then, install the Docker snap package on your Debian 12 system by utilizing the following command:
Method 5: Install Docker on Debian 12 From Docker Shell Script
Another most convenient and fastest way to install Docker on Debian 12 is using the Docker shell script. This shell script is provided by Docker to automate its installation process on the system. You can go through the given instructions to install Docker from the shell script on Debian 12:
Step 1: Download the Shell Script on Debian 12
First, download the Docker shell script on your Debian 12 system via the “curl” command with the name “get-docker.sh”:
Step 2: Install Docker on Debian 12
Next, install and set up Docker on Debian 12 by executing the following “get-docker.sh” script file through the below-listed command:
As you can see, this shell script has installed the Docker’s most recent version:
How to Manage Docker Service on Debian 12?
Once you have installed Docker on your Debian 12 system, you may want to manage its service to control Docker Daemon and containers. Managing Docker service includes starting, enabling, disabling, stopping, and restarting Docker services.
Here is the way to manage your Docker (daemon) services:
Start Docker Service
After installing Docker, if the Docker service is not started automatically, you can run the following command to start it on your system:
Enable Docker Service
To set the Docker daemon/service to start automatically on every system bootup, use the provided command:
Disable Docker Service
To prevent Docker services from starting automatically on system bootup, write out the below-listed command:
Stop Docker Service
To stop the Docker service on your system, you can execute the following command:
Restart Docker Service
If you want to restart the Docker service, execute the given command:
Display Status of Docker Service
To view the Docker service’s status, utilize the provided command:
The below output shows the information about the Docker service:
How to Configure Docker as a Non-root User on Debian 12?
On Debian systems, when you install Docker it generally runs with root privileges. As a result, running Docker commands without “sudo” gives permission errors as seen below:
In order to resolve this error and run Docker as a non-root user on Debian 12, check out the given instructions:
Step 1: Create a Docker group
First, you need to make a new Docker by utilizing the following command:
This has created the new Docker group named “docker”:
Step 2: Add User to Docker Group
Then, use the given command to add the current (or any new/existing) user to the docker group on your system:
Step 3: Restart Debian 12 System
You have to reboot/restart the Debian system to implement changes:
Step 4: Verification
Finally, run any Docker command to ensure that we can use and run Docker as a non-root user. Here we are executing the following Docker commands:
docker images
It can be seen that the Docker commands are executing without “sudo” successfully:
How to Remove Docker From Debian 12?
There are various methods to remove Docker from Debian 12 systems because of different installation ways. You can choose the desired uninstallation method and remove Docker based on the way you installed it.
Here are the Docker removal methods:
If Installed From Debian 12/Docker Repository or Shell Script
If Docker is installed on the Debian 12 system from the default Debian repository, the official Docker repository, or the Docker shell script, you can remove it via the following command:
Also, remove the added Docker repository from your Debian 12 system through the provided command:
Likewise, remove the Docker GPG key from the system using the following command:
If Installed From Deb Packages Files
If you have installed Docker on your system from the deb packages files, type out the given command to remove it from the Debian 12 system:
If Installed From the Snap Store
You can use the provided command to remove Docker from Debian 12 if it is installed from the Snap Store:
That is all about installing, managing, and uninstalling Docker on Debian 12 systems.
Note: For additional information, see Docker’s official documentation.
Final Thoughts
You can install Docker on the Debian 12 system from the default Debian repository, official Docker repository, Snap Store, deb files, or Docker shell script. In these methods, the Docker official repository and the deb package file methods are most recommended as these provide the most up-to-date version of Docker with the latest features and updates. On the other hand, the default Debian repository and Docker shell script method are the simplest and fastest ways to install Docker. This article has illustrated all the potential approaches to install, configure, manage, and remove Docker on Debian 12.
I am a technical writer with a knack for learning and exploring new technologies. As a Computer Science Graduate, my expertise lies in the fundamentals of Programming languages and Linux OS. I strive to provide users with in-depth and informative articles that can help them understand the core concepts of modern technologies.