Introduction

Docker is used for creating, deploying, and managing containers for application development. It uses OS virtualization to isolate containers and allow them to communicate with each other.

In this tutorial, you will learn how to install Docker on Debian 10.

tutorial on how to install docker on debian 10

Prerequisites

  • Debian 10 installed and configured
  • Access to a command line/terminal window
  • A user account with sudo privileges

Before You Begin

To set up Docker, you will need to prepare the system for installation. Deleting older versions of Docker packages and downloading the required dependencies speeds up the process.

Uninstall Default Docker Packages

The first step is to remove old versions of dockerdocker.io, and docker-engine that may already be on the system. These versions are not required for the latest stable release of Docker.

Delete the outdated packages by typing the following command in the terminal:

sudo apt-get purge docker lxc-docker docker-engine docker.io

Install Required Packages

Update the default repository with the command:

sudo apt-get update

Download the following dependencies:

sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common

By doing so, this allows you to add a new repository over HTTPS.

Installing Docker

There are several ways to install Docker:

  1. The standard and most practical approach is to set up Docker repositories and install the software from them.
  2. Alternatively, download the DEB package and install Docker manually. This method is recommended for users that have air-gapped systems with no access to the internet.
  3. If you have Raspbian, the only way to set up Docker is by using automated convenience scripts.

Install Docker Using the Repository on Debian 10

The best option for most users will be to install Docker from its official repositories. To do so, follow the steps outlined below.

1. Download Docker’s official GPG key to verify the integrity of packages before installing:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add –

2. Add the Docker repository to your system repository with the following command:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"

3. Update the apt repository:

sudo apt-get update

4. Install Docker Engine – Community (the latest version of Docker) and containerd:

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

5. The service will start automatically after the installation. Check the status by typing:

sudo systemctl status docker

check if docker service is running
6. You can also verify the installation by asking for the Docker version:

docker -v

ckeck docker version in centos

Install Docker Manually on Debian 10

Users who cannot install Docker from its repositories (or prefer not to) have the option of installing the software manually.

1.Navigate to the following URL:

https://download.docker.com/linux/debian/dists/

2. Click the version of Debian you are using. In this case, it is Buster.

download deb package to install docker on debian buster

3. Click pool > stable, and finally amd64.

steps for manually installing docker on debian 10

4. Next, you will see a list of all the available .deb packages, including the new releases and older versions. The list will consist of multiple versions of three essential Docker packages:

  • containerd
  • docker-ce-cli (Docker’s command user interface)
  • docker-ce

Unless you require a specific version, go for the latest stable release. Click the newest version for each software package to download them.

a list of all available docker packages for debian

The system will most often store the .deb files in the Downloads folder.

locate deb files for docker

5. Return to the command line and navigate to the Downloads folder with the following command:

cd Downloads

6. To set up Docker, use the dpkg command to install each of the three packages. Make sure to do it in the following order:

sudo dpkg -i containerd.io_1.2.6-3_amd64.deb

command to install containerd from deb file

sudo dpkg -i docker-ce-cli_19.03.3~3-0~debian-buster_amd64.deb

command to install docker-ce-cli from deb file

sudo dpkg -i docker-ce_19.03.3~3-0~debian-buster_amd64.deb

command to install docker-ce from deb file

Verify the Installation With a Hello World Image

The best way to ensure that the container service has been configured correctly is to run a hello-world test image.

docker run hello-world

The command automatically downloads the hello-world image. It also creates a container based on that image.

The following output will appear in the terminal, verifying that you have successfully configured Docker on Debian 10:

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

run hello world test image in docker

Uninstall and Remove Docker

If you need to uninstall Docker, run the following command:

sudo apt-get purge docker-ce

The command deletes the docker-ce package. However, any additional files related to it, such as images, containers, and custom configuration files, remain on the system. Remove everything from the Docker directory with the command:

sudo rm -rf /var/lib/docker

Conclusion

Now that you know how to install Docker on Debian 10, you can also get started with learning the basic commands and functions.

If you have never worked with Docker containers, we highly recommend reading how to list, start, and stop Docker containers next.