How to Install Docker Engine on Debian 11

You can install Docker Engine on Debian 11 in three different ways: through the repository, manual deb installation, and via script. Check out all these methods with this guide below.

The Docker Engine or “Docker” successfully became a standard containerization platform due to its efficiency and ease of setup. You can install it in different ways depending on your situation and preferences. If you’re trying to find the best method to install Docker Engine on Debian 11, we’ve got you covered.

What is Docker Engine?

Docker is an open-source platform that developers often add to their arsenal of tools. It has gained popularity because it enables users to deploy and manage containerized applications. Hence, it became a popular tool for running software in its environment, making it easier for testing, comparing, and deploying apps within limited resources.

These “containerized applications” are source codes integrated with operating system libraries. Unlike hypervisors, Docker doesn’t run another operating system on top of the native operating system to run environment-specific apps.

docker

Instead, Docker containers are treated and executed as isolated apps (not virtualized OS). These apps don’t require pre-allocated resources.

Due to its functionalities, a docker container is often used to develop, ship, and run applications quickly and securely. In addition, you can run multiple app instances within the same hardware because Docker uses fewer resources than virtualization. And since everything loads faster, the development process gets more efficient.

Docker Engine Installation Requirements

Before installing the Docker Engine on your computer, you need to be at least running the Buster 10 old table or the Bullseye 11 stable releases (for both Debian and Raspbian distros). You also need the 64-bit version or architectures armhf and arm64.

To cleanly install the latest version, you also need to remove any old versions of docker (with packages docker, docker.io, or docker-engine). The code below will remove any old docker installations.

$  sudo apt-get remove docker docker-engine docker.io containerd runc

If you have other projects from older versions, your files at var/lib/docker will be preserved. You must also take note that docker.io will now be called docker-ce upon upgrading, which is the latest version of the device.

Some users like using the old docker.io because it models itself to the Debian method of treating external dependencies at separate packages. The newer docker-ce, on the other hand, pulls every dependency on one tree source. But for this guide, we will be using the docker-ce version since it is the latest one supported by Docker.

Docker recommends using the repository method because it allows easy installations and upgrades. This is the recommended approach for Debian users except for Raspbian. You need to update your apt package index and enable HTTPS repository usage.

$ sudo apt-get install ca-certificates curl gnupg lsb-release
install docker engine on debian 11 via recommended option

And then add Docker’s official GPG key as follows:

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

You can then use this code snippet below to set up the stable repository. It should not give any reports to be considered a successful execution. Update your apt index again by using apt-get update.

$ echo \  "deb [arch=$(dpkg --print-architecture) 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 > /dev/nullc

To finally install docker-ce, you need to use this code which Docker officially recommends. The steps above are just to set up the repository to be pulled within the official download and installation channels.

$  sudo apt-get install docker-ce docker-ce-cli containerd.io
install docker engine ce

There are several stable versions of docker-ce that can be available simultaneously. Some versions might work better on your system and projects. Check the list of the available versions by running the first code, and then install a specific version using the subsequent one below.

$ apt-cache madison docker-ce
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
sample result

Check if your installation is running as intended by running the hello-world program. Running this program for the first time will require docker-ce to pull the resources from the database, so don’t panic if it takes quite a time.

$ sudo docker run hello-world
running the command

Once all the necessary resources are acquired, docker will run the hello-world test image as a container. You should get a result similar to the screenshot above.

Alternative Option (Manual Way)

If you’re having trouble accessing Docker’s repository or have limited bandwidth, your best bet is to install the package the manual way. Go to the Docker download website and select the Debian version you have installed.

Select pool > stable > amd64 (or your applicable architecture) and download the “.deb” file of the version that you prefer. Once downloaded, navigate to the .deb file and execute dpkg. Ensure that you have the contairerd.io, docker-ce-cli, and docker-ce deb files.

$ sudo dpkg -i *.deb
install docker engine on debian 11 by deb installation

To once again check if the installation was successful, let’s run the hello-world image once again. But this time, you need to start docker manually.

$ sudo systemctl start docker
$ sudo docker run hello-world
install docker engine on debian 11

Scripting (Automated Way)

Alternatively, you can use the convenience script provided by Docker to automate the installation. This option is the recommended way if you’re using Raspbian. Before blindly executing scripts in your machine, don’t forget to examine scripts from external sources.

Copy and paste the script and save it to any file, as long as it ends with the “.sh” extension. Make sure that the file can be run as executable. Navigate to your file via the Terminal and execute:

$ sudo ./filename.sh

Docker installation can vary from one Linux distro to another. If you’re trying to learn Docker using a Debian distro, I hope this guide has helped you install this platform into your system.

It is up to you to stay with your docker.io installation since it has its security advantage. But if you want convenience and ease, follow the steps above, and you should have no problem starting your docker. 

If this guide helped you, please share it. ?

Leave a Reply
Related Posts