Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install Docker on Debian

Add the official Docker repository to Debian and install Docker Engine, Compose and Buildx.

VPS and Cloud Servers2 min read9 screenshots

Why Docker on Debian

  • Simple app management. Containers hold an app and its needs.
  • Same behavior everywhere.
  • Isolation. Apps are kept apart, which helps security.
  • Stable base. Debian is known for its reliability.
  • Better workflows for developers and admins.

Step 1: Remove conflicting packages

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
Removing conflicting packages

It is fine if apt says that none are installed.

Step 2: Update the package list

sudo apt update
Updating the package list

Step 3: Install certificates and curl

sudo apt-get install ca-certificates curl
Installing ca-certificates and curl

Step 4: Create a folder for the key

sudo install -m 0755 -d /etc/apt/keyrings
Creating the keyrings folder

Step 5: Download the Docker key

sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
Downloading the Docker GPG key

Step 6: Make the key readable

sudo chmod a+r /etc/apt/keyrings/docker.asc
Setting the permission on the key

Step 7: Add the Docker repository

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Adding the Docker repository

Step 8: Install Docker

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Installing the Docker packages
  • docker-ce is Docker Community Edition, the main engine.
  • docker-ce-cli is the command-line tool.
  • containerd.io is the container runtime.
  • docker-buildx-plugin adds extra build features.
  • docker-compose-plugin adds Docker Compose.

Step 9: Test it

sudo docker run hello-world
The hello-world container

If you see a welcome message, Docker works.

Use Docker without sudo (optional)

sudo usermod -aG docker $USER

Log out and in again. Remember that users in the docker group have rights like root.

Features of Docker

  • Lightweight containers. They use few resources.
  • Portability. The same image runs on many platforms.
  • Versions. Images have tags, so rollbacks are easy.
  • Docker Compose for multi-container apps.
  • A large image library.
  • Isolation between apps.

Quick recap

  • Remove old packages, add the official repository and key.
  • Install docker-ce and the plugins.
  • Test with hello-world.