This guide provides step-by-step instructions for installing Docker Engine on a Debian-based system using Docker's official repository. This is the recommended method as it ensures you get the latest and most stable version.
Next, configure your system to download packages from the official Docker repository instead of the default Debian repository.
sudo apt-get update
sudo apt-get install ca-certificates curlThis step ensures that the packages you download are authentic.
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.ascThis command automatically detects your Debian version and sets up the repository accordingly.
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/nullNow you can install the latest version of Docker Engine and its related components.
sudo apt-get updateThe docker-compose-plugin package provides the docker compose command.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginRun the hello-world image to confirm that Docker Engine is installed and running correctly.
sudo docker run hello-worldIf the installation was successful, you will see a "Hello from Docker!" message in your terminal.
To avoid typing sudo every time you run a Docker command, add your user to the docker group.
sudo groupadd dockersudo usermod -aG docker $USERImportant: You need to log out and log back in for this change to take effect. Alternatively, you can run newgrp docker in your current terminal session to activate the new group membership.
After this, you can run Docker commands directly (e.g., docker ps).