Skip to content

Install Docker

This post explains how to install Docker on Debian or Ubuntu and which commands are useful.

Installation

  1. Update packages and install dependencies
sh
sudo apt update
sudo apt install ca-certificates curl gnupg -y
  1. Add the GPG key Debian:
sh
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Ubuntu:

sh
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
  1. Add repository
sh
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. Update packages and install Docker
sh
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
  1. Check if Docker is installed and working
sh
sudo docker run hello-world

Usefull Commands

Check Docker Service Status

sh
sudo service status docker

Show all containers

sh
docker ps -a

Start container

sh
docker start <name or id>

Stop the container

sh
docker stop <name or id>

Delete container

sh
docker rm <name or id>