What are the steps used to install Docker on Debian Linux systems?. How can I install Docker Compose on Debian Linux system?. In this guide, I’ll discuss a step by step installation of Docker and Docker Compose on Debian operating system.

Docker is the most popular and widely used container runtime. It enables you to package and run your applications in isolated containers in a single server or cluster of Linux servers orchestrated by Kubernetes and similar tools.

Docker Editions

There are two editions of Docker available.

  • Community Edition (CE): ideal for individual developers and small teams looking to get started with Docker and experimenting with container-based apps.
  • Enterprise Edition (EE): Designed for enterprise development and IT teams who build, ship, and run business-critical applications in production at scale.

This guide will cover installation of Docker CE on Debian Linux. But let’s first look at common docker terminologies.

Docker Components / Terminologies

Below are commonly used terminologies in Docker ecosystem.

  • Docker daemon: This is also called Docker Engine, it is a background process which runs on the host system responsible for building and running of containers.
  • Docker Client: This is a command line tool used by the user to interact with the Docker daemon.
  • Docker Image: An image is an immutable file that’s essentially a snapshot of a container. A docker image has a file system and application dependencies required for running applications.
  • Docker container: This is a running instance of a docker image with an application and its dependencies. Each container has a unique process ID and isolated from other containers. The only thing containers share is the Kernel.
  • Docker registry: This is an application responsible for managing storage and delivery of Docker container images. It can be private or public.

Install Docker CE on Debian 12/11/10

Follow the steps covered in the next parts of this article to install and use Docker CE on Debian.

1) Install Dependency packages

Start the installation by ensuring that all the packages used by docker as dependencies are installed.

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

2) Add Docker’s official GPG key

Import Docker GPG key used for signing Docker packages.

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-archive-keyring.gpg

3) Add the Docker repository

Add Docker repository which contain the latest stable releases of Docker CE.

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

This command will add the line shown in /etc/apt/sources.list file.

4) Install Docker and Docker Compose

Update the apt package index.

sudo apt update

To install Docker CE on Debian, run the command:

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y

Start and enable docker service:

sudo systemctl enable --now docker

This installation will add docker group to the system without any users. Add your user account to the group to run docker commands as non-privileged user.

sudo usermod -aG docker $USER
newgrp docker

Check docker and compose version.

 docker version

Checking compose plugin:

docker compose version

Log out and log back in so that your group membership is re-evaluated.

exit

Install Docker Compose manually

Use the guide below to install latest Docker Compose on Debian.

5) Test Docker installation

Run a test docker container:

$ docker run --rm -it  --name test alpine:latest /bin/sh
latest: Pulling from library/alpine
2408cc74d12b: Pull complete
Digest: sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c
Status: Downloaded newer image for alpine:latest

 / # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=x.y.z
PRETTY_NAME="Alpine Linux vx.y.z"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"

 / # exit

6) Test Docker Compose installation

Create a test Docker Compose file.

vim docker-compose.yml

Add below data to the file.

version: '3'  
services:
  web:
    image: nginx:latest
    ports:
     - "8080:80"
    links:
     - php
  php:
    image: php:7-fpm

Start service containers.

docker-compose up -d

Output:

docker compose start containers

Show running Containers

docker-compose ps

Destroy containers

$ docker-compose stop
$ docker-compose rm
Going to remove vagrant_web_1, vagrant_php_1
Are you sure? [yN] y
Removing vagrant_web_1 … done
Removing vagrant_php_1 … done

You have successfully installed Docker on Debian Linux. Go through Official Docker documentation and Docker Compose documentation to learn more.

7) Docker & Compose CLI Commands

Below is a table that summarized common Docker and Compose CLI commands:

CommandDescription
Docker Commands
docker versionCheck Docker version and information
docker infoDisplay Docker system-wide information
docker pull <image>Pull an image from a registry
docker run <image>Run a container from an image
docker psList running containers
docker ps -aList all containers (including stopped ones)
docker stop <container>Stop a running container
docker rm <container>Remove a container
docker imagesList local images
docker rmi <image>Remove an image
docker exec -it <container> <command>Execute a command in a running container interactively
docker logs <container>Fetch the logs of a container
Docker Compose Commands
docker compose upStart services defined in docker-compose.yml
docker compose downStop and remove containers, networks defined in docker-compose.yml
docker compose logsView output from containers
docker compose psList containers
docker compose exec <service> <command>Execute a command in a running service container
docker compose buildBuild or rebuild services
docker compose restart <service>Restart services
docker compose stop <service>Stop services

Setup Docker UI (Optional)

If you need a UI management console for Docker hosts and containers, checkout Portainer.

Monitoring Docker containers

Monitoring Docker containers can be achieved by using Monitoring tools such as Netdata, Prometheus and Grafana. Below guide should also be helpful Check Container container metrics with Ctop.

9 COMMENTS

  1. Hello, just wanted to reach out and let the writer know that this installation guide does not work. Fails on the run migrations in task container task every time.

  2. Excellent tutorial! I used it to install Docker on my Chromebook (Linux terminal). Everything is up and running.

    I was getting the error “docker-compose: command not found” when testing the yml file in Docker Compose. I ended up needing to run the following line and then all worked great.

    $sudo apt install docker-compose

  3. Thank you again for the amazing piece of work!

    Docker is truly awesome and works seamlessly with Portainer. In the world of computing, many DevOps tools have been a lifesaver, particularly when it comes to software development. Without Linux and container technology, we would be struggling to manage and deploy applications efficiently, and the process of software development would be much more challenging. The benefits that containerization provides, such as increased portability and scalability, have revolutionized the industry and enabled more efficient and streamlined software development.

LEAVE A REPLY

Please enter your comment!
Please enter your name here