How to Install Docker CE on Debian 12

|
Last Updated:
|
|

In this tutorial, we are going to learn how to install Docker CE on Debian 12. Docker is a platform that enables developers and system administrators to build, run, and share applications in container format. A container is a unit of software that packages code and its dependencies so the application runs quickly and reliably across computing environments.

Installing Docker CE Debian 12

The exits two editions of docker available. Docker CE and Docker EE

  • Docker CE (Community Edition) is the open-source, community supported version of Docker and is available for free.
  • Docker EE (Enterprise Edition) is a commercial/premium version of Docker CE and is support by Docker Inc.

There are different methods in which you can install Docker CE;

Installing Docker CE from Docker Repositories

To install Docker CE from Docker, you first need to install some required packages by executing the command below. Some of the package may already be installed though;

apt update
apt install apt-transport-https ca-certificates \
curl gnupg-agent software-properties-common

Next, install Docker repository GPG signing key.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor > /etc/apt/trusted.gpg.d/docker.gpg

Install Docker repository on Debian 12.

echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -sc) stable" \
> /etc/apt/sources.list.d/docker-ce.list

After that, update package cache.

apt update

Install Docker CE and other tools including containerd.io, An open and reliable container runtime.

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

Note that, even if you install just docker-ce package, other tools like docker-ce-cli and containerd.io will be installed along with it.

apt install docker-ce

Installing Docker CE using DEB Binary Package

If you want to go the manual way, you can simply download Docker CE DEB binary package for your specific system version from https://download.docker.com/linux/debian/dists/bookworm.

For example, in this case grab the .deb files.

To download docker-ce, docker-ce-cli and containerd.io, you would simply pull them as follows;

wget https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-ce_24.0.2-1~debian.12~bookworm_amd64.deb
wget https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-ce-cli_24.0.2-1~debian.12~bookworm_amd64.deb
wget https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/containerd.io_1.6.21-1_amd64.deb

You can then install them using the apt or dpkg package manager. Be sure to install docker-ce-cli and containerd.io before docker-ce.

apt install ./docker-ce-cli_24.0.2-1~debian.12~bookworm_amd64.deb
apt install ./containerd.io_1.6.21-1_amd64.deb
apt install ./docker-ce_24.0.2-1~debian.12~bookworm_amd64.deb

Checking Installed Docker Version

To check the version of installed Docker, simply run the command;

docker --version
Docker version 24.0.2, build cb74dfc

Starting Docker Service

To start and enable Docker and Containerd service to run on system boot;

systemctl enable --now docker

Check status;

systemctl status docker

● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled)
     Active: active (running) since Fri 2023-06-16 20:29:39 EAT; 54min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 6123 (dockerd)
      Tasks: 9
     Memory: 44.3M
        CPU: 567ms
     CGroup: /system.slice/docker.service
             └─6123 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jun 16 20:29:38 bookworm systemd[1]: Starting docker.service - Docker Application Container Engine...
Jun 16 20:29:38 bookworm dockerd[6123]: time="2023-06-16T20:29:38.633036521+03:00" level=info msg="Starting up"
Jun 16 20:29:38 bookworm dockerd[6123]: time="2023-06-16T20:29:38.844929428+03:00" level=info msg="Loading containers: start."
Jun 16 20:29:39 bookworm dockerd[6123]: time="2023-06-16T20:29:39.158737769+03:00" level=info msg="Loading containers: done."
Jun 16 20:29:39 bookworm dockerd[6123]: time="2023-06-16T20:29:39.278964922+03:00" level=info msg="Docker daemon" commit=659604f graphdriver=overlay2 version=24.0.2
Jun 16 20:29:39 bookworm dockerd[6123]: time="2023-06-16T20:29:39.279291221+03:00" level=info msg="Daemon has completed initialization"
Jun 16 20:29:39 bookworm dockerd[6123]: time="2023-06-16T20:29:39.324481047+03:00" level=info msg="API listen on /run/docker.sock"
Jun 16 20:29:39 bookworm systemd[1]: Started docker.service - Docker Application Container Engine.

Running Docker as a non-root user

If you run Docker as standard system user, you may get such an error;

docker run hello-world
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: ...
/var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

Therefore, if you need to run docker as non-root user, simply add the user you want to run docker as to docker group or simply, grant the user sudo rights. For example to add current logged in user to docker group;

sudo usermod -aG docker $USER

Once you have added the user to the Docker group, log out and login again to have the user group membership re-evaluated.

You can then run docker as the standard user.

Verifying Docker CE installation

To verify that Docker CE is running well, you can try running the hello-world container image.

docker run hello-world

NOTE: If you still get the same permission denied error after adding user to docker group, logout and login again and you should be able to run docker as a standard user.


Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:8e3114318a995a1ee497790535e7b88365222a21771ae7e53687ad76563e8e76
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

To list running containers;

docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
4083300e3660        hello-world         "/hello"            5 minutes ago       Exited (0) 5 minutes ago                       recursing_tereshkova

There you go. You have successfully installed Docker CE on Debian 12. You can now explore Docker further.

Reference

Docker Engine Installation on Ubuntu

Other Tutorials

Step-by-Step Guide on Deploying an Application on Kubernetes Cluster

Install Portainer on Rocky Linux

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
Kifarunix
Linux Certified Engineer, with a passion for open-source technology and a strong understanding of Linux systems. With experience in system administration, troubleshooting, and automation, I am skilled in maintaining and optimizing Linux infrastructure.

Leave a Comment