Docker is the most widely used and popular container runtime. It allows you to package and run your applications in isolated containers on a single server or in a cluster of Linux servers orchestrated by Kubernetes and other similar tools.
In this guide, we will take you through how to Install Docker CE on Debian 11|Debian 10.
Docker Editions
Docker is available in two editions.
- Community Edition (CE): Perfect for developers working alone or in small groups who want to try out container-based projects and learn more about Docker.
- Enterprise Edition (EE): Developed for IT and enterprise development teams who create, launch, and manage to scale business-critical applications in production.
Install Docker CE on Debian 11|Debian 10
The following steps will take you through the installation of Docker CE on Debian 11|Debian 10.
Step 1: Install Debian 11|Debian 10 Linux Dependencies
The following command should first be used to update the Debian server.
sudo apt update
Afterward, you should run the following command on the Debian-based Distro to install the dependencies needed for Docker to function.
sudo apt install apt-transport-https lsb-release ca-certificates curl gnupg -y
Step 2: Install Docker Repository on Debian 11|Debian 10
Utilize the link below to download the Docker GPG key, then add it.
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Then, use the following command to add the downloaded repository:
$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list
deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian bullseye stable
Use the below command for updating the packages list:
sudo apt update
Step 3: Install Docker Engine on Debian 11|Debian 10
Use the following command to download and install the most recent version of the Docker engine and container:
sudo apt-get install docker-ce docker-ce-cli containerd.io
Sample output:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
linux-image-5.10.0-9-amd64
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
docker-buildx-plugin docker-ce-rootless-extras docker-compose-plugin docker-scan-plugin git git-man liberror-perl libslirp0 patch pigz
slirp4netns
Suggested packages:
aufs-tools cgroupfs-mount | cgroup-lite git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs
git-mediawiki git-svn ed diffutils-doc
The following NEW packages will be installed:
containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin docker-scan-plugin git
git-man liberror-perl libslirp0 patch pigz slirp4netns
0 upgraded, 14 newly installed, 0 to remove and 81 not upgraded.
Need to get 119 MB of archives.
After this operation, 439 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up slirp4netns (1.0.1-2) ...
Setting up docker-ce (5:23.0.1-1~debian.11~bullseye) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Setting up git (1:2.30.2-1+deb11u1) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.31-13+deb11u4) ...
Check the Docker version installed;
$ docker --version
Docker version 23.0.1, build a5ee5b1
To check whether the Docker service is running or not on our Debian system, we will run the “systemctl” command with the “status” argument during our course:
sudo systemctl status docker
Sample output:
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2023-02-18 04:17:03 EST; 3min 13s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 4245 (dockerd)
Tasks: 8
Memory: 31.7M
CPU: 591ms
CGroup: /system.slice/docker.service
└─4245 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Feb 18 04:16:51 debian dockerd[4245]: time="2023-02-18T04:16:51.577430001-05:00" level=info msg="[core] [Channel #4 SubChannel #5] Subcha>
Feb 18 04:16:51 debian dockerd[4245]: time="2023-02-18T04:16:51.577908197-05:00" level=info msg="[core] [Channel #4] Channel Connectivity>
Feb 18 04:16:53 debian dockerd[4245]: time="2023-02-18T04:16:53.971610655-05:00" level=info msg="Loading containers: start."
You may start and enable Docker using the following command:
sudo systemctl start docker
sudo systemctl enable docker
Step 4: Test Docker
As of right now, Docker has been installed on our Debian system, and its status has been checked.
What will come next?
You may inquire. We’ll run an example container to test Docker’s functionality. We’ll essentially try to run a global “hello-world” Docker container.
sudo docker run hello-world
Sample output:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:6e8b6f026e0b9c419ea0fd02d3905dd0952ad1feea67543f525c73a0a790fefb
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/
Step 5: List Docker Images
The docker images command may then be used to run a list of all the available images. Please note the similarity between the commands’ docker images and docker image.
sudo docker images
Sample output:
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 17 months ago 13.3kB
Step 6: Run Ubuntu Container
Here, you can start an Ubuntu Container using the docker run -it ubuntu bash command. Ubuntu: newest picture will be automatically searched for if you don’t include a specific tag with the image.
The image will be obtained from the Ubuntu Library and used to create the container if it is not already present on your local machine.
Run for this to happen.
sudo docker run -it ubuntu bash
Sample output:
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
677076032cca: Pull complete
Digest: sha256:9a0bdde4188b896a372804be2384015e90e3f84906b750c1a53539b585fbbe7f
Status: Downloaded newer image for ubuntu:latest
root@fbaf549a2281:/#
Final Thoughts
A software framework called Docker is used for fast developing, testing, and deploying applications.
Everything your application needs to execute, including system tools, libraries, code, and runtime, is organized into containers by the system as applications or packages. With Docker, you can quickly deploy and grow apps in any environment. How to install Docker on Debian was demonstrated in this article. In addition, we demonstrated how to test Docker on your Debian 11|Debian 10 system.
Read more about Docker.
See more on these guides: