Prerequisites
OS requirements
To install Docker Engine, you need the 64-bit version of one of these Debian or Raspbian versions:
- Debian Bullseye 11 (stable)
- Debian Buster 10 (oldstable)
- Raspbian Bullseye 11 (stable)
- Raspbian Buster 10 (oldstable)
Docker Engine is compatible with x86_64 (or amd64), armhf, and arm64 architectures.
Uninstall old versions
Older versions of Docker went by the names of docker, docker.io, or docker-engine. Uninstall any such older versions before attempting to install a new version:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
It’s OK if apt-get reports that none of these packages are installed.
Images, containers, volumes, and networks stored in /var/lib/docker/ aren’t automatically removed when you uninstall Docker. If you want to start with a clean installation, and prefer to clean up any existing data, refer to the uninstall Docker Engine section.
.#1 Update a Package List
Make sure your package list is up to date by opening a terminal and running the following command.
sudo apt update
#2 Install Required Packages
Install the required packages to enable apt to use HTTPS repositories and support other package types.
sudo apt install apt-transport-https ca-certificates curl software-properties-common
#3 Add Docker Repository
You can add Docker’s official GPG key and repository to your system by following these steps.
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
#4 Update Package List Again
Please run the update command again to ensure that the Docker repository is included.
sudo apt update
#5 Install Docker Engine
Install Docker Engine and its dependencies.
sudo apt install docker-ce docker-ce-cli containerd.io
#6 Start and Enable Docker
Start the Docker service and enable it to start on boot. First run the command:
sudo systemctl start docker
To automatically launch alongside the operating system, include it in the startup configuration with this command.
sudo systemctl enable docker
#7 Verify Installation
To ensure that Docker is up and running, try running a basic container with a “Hello World” command.
sudo docker run hello-world
Congratulations! You have successfully installed Docker on Debian 11. Get ready to efficiently manage and run containers for your applications.