Skip to content
lanzai.co
Go back

Installing Docker on Ubuntu/Debian

Docker is the most popular container runtime. Here are the steps to install it on Ubuntu / Debian.

Remove old versions

sudo apt remove docker docker-engine docker.io containerd runc

Set up the repository

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/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list

Install Docker

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

Use Docker without sudo

sudo usermod -aG docker $USER
# Log out and back in, or run: newgrp docker

Verify

docker run hello-world
docker compose version

Optional: registry mirrors

Edit /etc/docker/daemon.json:

{ "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"] }

Then restart: sudo systemctl restart docker.


Share this post:

Previous Post
Building a Bilingual Blog with Astro
Next Post
Installing Docker Compose and Common Commands