How to Install Docker on Debian 10

Docker is an OS-level virtualization solution built around Linux kernel features like namespaces and cgroups to provide isolation for software packages called containers. This article will walk you through the process of installing and starting Docker on your Debian 10 server.

Prerequisites:

  • You need access to a Linux server, with sudo or root privileges.

Installation:

Before installing the Docker package, we will ensure the package cache is up to date.

$ sudo apt-get update

We will then install some needed dependencies.

$ sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Next up, we need to import the gpg public key for the Docker CE repository

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

Now that the gpg public key has been added, we can add the Docker CE repository.

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

Update the package cache to recognize the new repository.

$ sudo apt-get update

Install the Docker-CE package.

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

Configuration:

First, we must configure a user if we want to run docker without root privileges.  I have created a user called test_user.  The following command will add the user “test_user” to the docker group.

$ sudo usermod -a -G docker test_user

In order for the changes to be recognized, you must log out and back into your existing shell session or use the following command.

$ su test_user

Verification:

We can use systemctl to ensure the docker service is started and set to enabled at boot.

$s udo systemctl status docker.service

Check which docker version is installed.

$ docker --version

Run a test container. If this completes successfully, then you have successfully configured the docker service.

$ docker run hello-world

Conclusion

In this article, you learned how to install, configure, and verify the docker service on Debian 10.  Check out the official docker documentation for more information.