In this guide we are going to install Docker on Debian 10 Buster. To be able to use Docker to its full extent, we also install docker-compose. There are two ways to install the Docker Engine, one with a regular apt install and one with an install script made by docker.

Install Docker from apt repo

First, we make sure to remove all versions of Docker. This is especially important if you have ever tried to install Docker on your Debian server before.

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

1. Preparation

sudo apt-get update
sudo apt-get install \
   apt-transport-https \
   ca-certificates \
   curl \
   gnupg \
   lsb-release

2. Add Docker GPG key

This GPG key verifies the Docker packages that are loaded via apt. This ensures that only the real Docker packages are installed.

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

3. Set up Docker repository.

Now we’ll set up the Docker stable repository. If you prefer to install Docker from the testing or nightly repo, you can simply replace stable with testing, or nightly respectively. For production use, however, I strongly recommend using the stable version.

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 > /dev/null

4. Install Docker

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

5. Test Docker installation

From now on, Docker is available on your server. Finally, you can use the following Docker image to test if Docker was installed correctly.

sudo docker run hello-world

If everything worked, this container should give you “Hello World” and exit automatically.

Docker install script

Even easier and faster Docker can be installed automatically on your server with the following command.

Info

With this type of installation, you must trust that the Docker installation script is really available under the specified link. If there is malicious code in this file, you would execute it unhindered on your server. I recommend you to install Docker with apt.

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

install docker-compose

Contrary to Docker installation, there is no separate package for docker-compose, which can be installed via the official Docker repo. The installation is done directly from Github, on the following page you can find all docker-compose releases that are available.

To install the latest version of docker-compose on Debian 10, the following command is used.

sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

To test the installation of docker-compose, you can use the following command. This should show you the version of docker-compose, if the installation was successful.

docker-compose --version