How to Install and Use Docker on Debian 10 Linux

Published on

4 min read

Install and Use Docker on Debian 10 Buster

Docker is a containerization platform that allows you to quickly build, test and deploy applications as portable, self-sufficient containers that can run virtually anywhere.

In this tutorial, we’ll explain how to install Docker on Debian 10 Buster and explore the basic Docker concepts and commands.

Install Docker on Debian

Perform the following steps to install the latest stable Docker version from the Docker’s repositories.

  1. Install the packages necessary to add a new repository over HTTPS:

    sudo apt updatesudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg2
  2. Import the repository’s GPG key using the following curl command :

    curl -fsSL | sudo apt-key add -

    On success, the command will return OK.

  3. Add the stable Docker APT repository to your system’s software repository list:

    sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

    $(lsb_release -cs) will return the name of the Debian distribution . In this case, that is buster.

  4. Update the apt package list and install the latest version of Docker CE (Community Edition):

    sudo apt updatesudo apt install docker-ce
  5. Once the installation is completed the Docker service will start automatically. To verify it type in:

    sudo systemctl status docker
    ● docker.service - Docker Application Container Engine
    Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
    Active: active (running) since Tue 2019-07-30 20:52:00 GMT; 1min 11s ago
  6. At the time of writing, the latest stable version of Docker is 19.03.1:

    docker -v
    Docker version 19.03.1, build 74b1e89

Executing the Docker Command Without Sudo

By default, only root and user with sudo privileges can execute Docker commands.

If you want to execute Docker commands without prepending sudo you’ll need to add your user to the docker group which is created during the installation of the Docker CE package. To do that, type in:

sudo usermod -aG docker $USER

$USER is an environment variable that holds your username.

Log out and log back in so that the group membership is refreshed.

Once done to verify that you can run docker commands without sudo type in:

docker container run hello-world

The command will download a test image, run it in a container, print a “Hello from Docker” message and exit. The output should look like the following:

Docker Hello World

Using Docker

Now that you have installed on your Debian 10, let’s go over the basic docker concepts and commands.

Docker Images

A Docker image is made up of a series of filesystem layers representing instructions in the image’s Dockerfile that make up an executable software application. An image is an immutable binary file including the application and all other dependencies such as libraries, binaries, and instructions necessary for running the application.

Most Docker images are available on Docker Hub . It is a cloud-based registry service which among other functionalities is used for keeping the Docker images either in a public or private repository.

To search for an image from the Docker Hub registry, use the docker search command. For example, to search for a Debian image, you would type:

docker search debian

Docker Containers

An instance of an image is called a container. A container represents a runtime for a single application, process, or service.

It may not be the most appropriate comparison but if you are a programmer you can think of a Docker image as class and Docker container as an instance of a class.

To start, stop, remove and manage a container use the docker container command. For example, the following command will start a Docker container based on the Debian image. If you don’t have the image locally, it will be downloaded first:

docker container run debian

The Debian container will stop immediately after booting up because it does not have a long-running process and no other command is provided. The container booted up, ran an empty command and then exited.

The switch -it allows you to interact with the container through the command line. To start an interactive container type:

docker container run -it debian /bin/bash

As you can see from the output above once the container is started the command prompt is changed which means that you’re now working from inside the container .

To list running Docker containers , use the following command:

docker container ls

If you don’t have any running containers the output will be empty.

To view all containers, pass it the -a switch:

docker container ls -a

To delete one or more containers just copy the container ID (or IDs) and paste them after the container rm command:

docker container rm c55680af670c


Installing Docker on Debian 10 is a relatively easy task. Docker is de facto standard for container technology and it is an essential tool for DevOps engineers and their continuous integration and delivery pipeline.

For more information check out the official Docker documentation .

If you have any questions, please leave a comment below.