Installing Docker on Debian
Docker supports the following 64-bit Debian versions:
- Debian Bookworm 12 (stable)
- Debian Bullseye 11 (oldstable)
Supported architectures include x86_64 (amd64), armhf, arm64, and ppc64le.
Uninstall Old Versions
If you previously installed Docker Engine, you need to uninstall the old version to avoid conflicts:
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
Automatic Installation Using the Official Installation Script
The installation command is as follows:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Manual Installation
1. Update Packages
First, update the existing packages and the package cache:
sudo apt update
sudo apt upgrade
2. Install Dependency Packages
Install the required dependency packages that allow apt to access the Docker repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
3. Add Docker's Official GPG Key
Use the following command to add Docker's official GPG key:
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
4. Add the Docker Repository
Add the official Docker APT 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-get update
5. Update the APT Package Cache
After adding the repository, update the APT package index:
sudo apt update
Make sure you are installing Docker from the official Docker repository rather than the default Debian repository:
apt-cache policy docker-ce
You should see it pointing to https://download.docker.com/; make sure this is the official Docker repository.
6. Install Docker
Now you can install Docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
7. Start and Verify Docker
Start Docker and enable it to run at boot:
sudo systemctl start docker
sudo systemctl enable docker
You can use the following command to verify that Docker was installed successfully:
sudo docker --version
Run the following test command to make sure Docker is working properly:
sudo docker run hello-world
Uninstalling Docker
Remove the installation package:
sudo apt-get purge docker-ce
Delete images, containers, configuration files, and so on:
sudo rm -rf /var/lib/docker