Install Docker and Docker Compose on Debian, quickly.

Tiempo de lectura: < 1 minuto

Today we’re going to learn how we can install Docker and Docker Compose on Debian very quickly.

First, we add the Debian repository keys.

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
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

Now we install the latest version of Docker

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

Run Docker

sudo docker run hello-world

We can configure so that we don’t need to use the sudo command to launch Docker (https://docs.docker.com/engine/install/linux-postinstall/):

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

Finally, Docker will work without the need for sudo command

docker run hello-world

*To run docker-compose we’ll use:

docker compose <command>

Leave a Comment