Step 1 — Install prerequisites & add Docker's GPG key
sudo apt update
sudo apt install -y 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
Step 2 — 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 update
Step 3 — Install Docker
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
After installation, start and enable the Docker service so it runs automatically at boot:
sudo systemctl start docker sudo systemctl enable docker
If you want to run Docker commands without using sudo, you need to add your user to the docker group. Execute these commands:
sudo usermod -aG docker $USER
Then
newgrp docker
This allows your user account to execute Docker commands directly. Test it using:
docker run hello-world
Debian