Greenwebpage Community Blog Tutorials How to Install Docker on Debian 12: All Possible Methods
Tutorials

How to Install Docker on Debian 12: All Possible Methods

Docker has increasingly been embraced as a fundamental tool for managing and deploying software applications. It is a containerization system that enables users to modularize and execute their software applications in self-sufficient environments called containers. Docker can be run and used on multiple platforms, such as Windows, MacOS, and Linux distributions like Debian.

This tutorial will explain how to install Docker on a Debian 12 system by using different methods.

How to Install Docker on Debian 12?

Docker can be installed using the following methods on a Debian 12 system:

Method 1: From Default Debian Repository

Docker can be found as part of the software package collection in the default Debian repository. This is the most straightforward way to install Docker, However, it is highly recommended to avoid installing it this way, as the version of Docker provided is outdated. Follow the instructions below to install Docker on your Debian 12 using this method.

Step 1: Update Debian System

Before beginning the installation of Docker, you are only a few steps away from getting your system updated. Copy and paste these commands, and your system’s packages will be updated:

sudo apt update
sudo apt update

Now, this will refresh Debian’s repository packages.

Step 2: Install Docker

Now, with the help of this command, you can install the Docker package “docker.io” from the official Debian repository:

sudo apt install docker.io -y

Step 3: Verify Installation

To verify that Docker has been installed on your Debian system, execute the below command to check its version:

docker --version

As you can see, the output shows the version of Docker that is installed in the system:

Method 2: From the Official Docker Repository

By installing it from the official Docker repository, you will be able to install the latest versions with ease. This method offers up-to-date docker packages with the latest features and updates. Furthermore, it will even go the extra mile and fetch the new version of Docker and automatically install it via the package manager as soon as it is available in the official repository.

Follow these steps so that you can install Docker on your Debian 12 system:

Step 1: Install Required Dependencies

Copy and execute these commands if you want to install the docker on your Debian 12 system:

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

Step 2: Import Docker GPG Key

Next, let’s move on to import the Docker GPG key with the command provided above to validate the integrity of the packages.

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

Step 3: Add Docker Repository to Debian 12

Following that, you can add/import the Docker’s proprietary repository to the system in Debian 12.

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 System’s Packages

Now, update your system for the implementation of new changes.

sudo apt update

Step 5: Install Docker

Now, you can install the new and required packages of Docker which are “docker-ce” docker engine community edition, “docker-ce-cli” command line interface for docker, and “containerd.io” container runtime found within the below command.

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

Step 6: Verification

Finally, you can run the docker version command to check the version installed on your machine, and it is observed that Docker’s latest version has been installed successfully.

docker --version

It can be observed that the Docker’s latest has been successfully installed:

Method 3: From the Deb Package File

Another way of downloading Docker is by going to the official page and downloading the latest version by opening and using the Deb package file. This is how you can install Docker on Debian 12 through the Deb package file.

Step 1: Download Docker Package Files

To begin, navigate to the official Docker website, copy the required link for the latest Docker deb file, open your terminal, and paste the command ‘wget’ to download it to your device. At this step, we are fetching the Debian packages for the “containerd.io”, “docker-ce”, and “docker-ce-cli” files.

For “containerd.io”:

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

For “docker-ce”:

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

For “docker-ce-cli”:

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

You may also opt to get the Docker deb files from their site by simply visiting the website on the links.

Step 2: Installing Docker

Next, proceed to install the downloaded deb files with this command to ensure you have Docker’s latest version:

sudo apt install ./containerd.io_1.6.28-1_amd64.deb

Step 3: Verify Installation

To confirm you have Docker installed on your machine, run the command below to see the version of Docker installed:

docker --version

The output presented below depicts the most recent version of Docker that is currently operational on the machine.

Method 4: From the Snap Store

The Snap Store has a Docker snap package that can be effortlessly added to Debian 12 using the snap command. The Docker installation for Debian 12 through the Snap store can be done using the following instructions.

Step 1: Install and Enable Snap

The Snap package manager is not available by default on the Debian 12 Operating System. Therefore, it should first be enabled for Snap packages including Docker.

Step 2: Install Docker on Debian 12

Then install Docker’s snap package on your Debian 12 Operating System using the command below:

sudo snap install docker

Method 5: From Docker Shell Script

One of the easiest and also fastest ways to configure Docker on Debian 12 would be by using the provided Docker shell script. Docker provides this shell script to streamline the process of configuring Docker on the user’s system. You can check the instructions given below to configure Docker from the shell scripts on Debian 12:

Step 1: Download the Shell Script

First, use the ‘curl’ command to fetch and store the shell script on the user’s Debian 12 system. The name of the file would be ‘get-docker.sh’:

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

Step 2: Install Docker

Now configure Docker on Debian 12 using the downloaded ‘get-docker.sh’ file with the command listed below:

sudo sh get-docker.sh

You can view that this shell script has configured Docker with its latest version installed:

docker --version

Final Thoughts

Docker can be installed on the Debian 12 system through the default Debian repository, Snap Store, official Docker repository, deb files, or via a shell script. While the default Debian repository and download script are arguably the quickest methods of installation, Docker’s official repository and the deb files methods are far superior, as they will provide you with the latest version of Docker with new features.

Frequently Asked Questions

Docker is an open-source platform used for automating the deployment, scaling, and management of applications in lightweight, portable containers.
Ensure that your Debian 12 system is up-to-date and has sudo privileges. It's also recommended to have at least 2 GB of RAM.
Run sudo apt update && sudo apt upgrade -y to update your system and ensure you have the latest software packages.
Use the command sudo apt install docker.io to install Docker from the default Debian repository.
After installation, enable Docker to start on boot using sudo systemctl enable docker, and start the service with sudo systemctl start docker.

Exit mobile version