To simplify the process of developing, testing, and running applications specifically in Linux operating systems like Debian 12 there are various tools one of which is Docker. It uses the operating system-level virtualization to run the software from containers. Containers are a complete application package that includes all its scripts, dependencies, and libraries, isolating the respective software or application from the rest of the system. To install Docker on Debian 12 there are several ways which this blog post will discuss.
How To Install Docker on Debian 12
To install Docker on Debian 12 there are three ways two of them install its CLI version and the third one installs its GUI version also known as Docker desktop. You need to install four packages on Debian to get Docker installed. These include the following:
docker-ce-cli: This package provides the command-line interface (CLI) for interacting with Docker Engine. It allows you to run commands to build, run, stop, and manage your containers from the terminal.
containerd.io: This is a separate project from Docker, but it’s a core dependency for Docker Engine. It’s a low-level container runtime that manages the underlying container processes and their lifecycle.
docker-buildx-plugin: This is an optional plugin that extends Docker Engine’s build capabilities. It allows you to build Docker images for different architectures (e.g., ARM, ppc) or use advanced caching mechanisms during the build process.
docker-compose-plugin: This is another optional plugin that simplifies working with Docker Compose. Docker Compose is a tool for defining and running multi-container applications. This plugin integrates Docker Compose functionality directly into the Docker CLI, making it easier to manage your multi-container setups.
In a nutshell, docker-ce and docker-ce-cli are the essential duo for running Docker whereas containerd.io is an underlying dependency for container runtime. The docker-buildx-plugin and docker-compose-plugin are optional add-ons for advanced build functionalities and managing multi-container applications.
1: Through Docker Repository
One way to install Docker on Debian is by adding its official repository into the advanced packing tool and for that first add its GPG key so that the system can verify that it is from the official source:
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
Now add the Docker repository in the Debian 12 sources list file and sign it using the GPG key added in the first step:
|
---|
It is necessary to update the package list for apt to add any repository successfully so for that use:
sudo apt update
Now install Docker and its four other packages on Debian by using the below command:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
To validate the installation of Docker run its default hello-world program:
sudo docker run hello-world
Further, you can also verify the installation by using the version command as well:
docker --version
2: Through Deb File
To install Docker on Debian 12 using the deb file provides a way to install its latest version, but the catch-22 is that you have to download each package and then install it manually. To download all the packages visit the Docker download page and then click on the desired version of each module to get their deb files:
Here I have downloaded both the optional plugins as well:
Once you have downloaded all the deb files you can verify by checking the respective download folder:
Use the Debian package manager to install all of these modules, you can set the command below if you have downloaded different versions:
sudo dpkg -i ./containerd.io_1.6.16-1_amd64.deb \
./docker-ce_23.0.0-1~debian.12~bookworm_amd64.deb \
./docker-ce-cli_23.0.0-1~debian.12~bookworm_amd64.deb \
./docker-buildx-plugin_0.10.2-1~debian.12~bookworm_amd64.deb \
./docker-compose-plugin_2.15.1-1~debian.12~bookworm_amd64.deb
Now start the Docker service and then verify it by checking its status using the systemctl utility:
sudo systemctl start docker
sudo systemctl status docker
To verify if Docker is installed correctly and is running without any errors then run its default hello-world program:
sudo docker run hello-world
3: Through Docker Desktop Deb File
Docker as mentioned previously comes with a GUI version which is best for users who need to get along with using commands on Debian 12 or other Linux distributions. Furthermore, the GUI version also makes it easy to use Docker. Docker desktop can be installed via its deb file so to download it visit the download page of Docker’s official site:
Now use the Debian default package installer to install Docker desktop using its deb file:
sudo apt install ./docker-desktop-4.28.0-amd64.deb
Launch the Docker desktop application by searching it in the application menu:
How To Fix KVM Not Enabled on Host in Debian 12
If you see an error KVM not enabled then it means that virtualization is not enabled on your system:
I have been running Debian 12 on Virtualbox so the method for enabling the virtualization support is different. However, if you have installed Debian on the system then all you have to do is to turn the virtualization on from the BIOS menu. The below image shows the option that I need to turn on to enable virtualization support for the Docker desktop:
To enable virtualization you need to first copy the path of the directory where the virtual box is installed on your system:
Now launch the PowerShell with admin rights and move to the directory of the VirtualBox:
cd "<path-to-virtualbox-directory>"
Now use the modifyvm command along with the machine name and turn on the virtualization by using:
.\VBoxManage modifyvm "<virtual-machine-name> " --nested-hw-virt on
Next, verify the changes by navigating to the processor settings under the system option of VirtualBox:
Now launch the Docker on Debian 12 and the issue will be fixed:
Conclusion
Docker on Debian 12 can be installed in three ways: through the Docker repository, its deb file, or using the deb file for the Docker desktop. If you are not comfortable with using the commands then in that case you should try the desktop version of Docker otherwise stick to the CLI version.