Docker is a powerful platform that simplifies the deployment and management of containerized applications. In this guide, we’ll walk you through the steps required to install Docker on Debian 12.
Prerequisites
- A system running Debian 12 (Bookworm)
- A user account with
sudo
privileges - Internet connection to download Docker packages
Step 1: Update Your System
Before installing Docker, it’s essential to update the package index and upgrade existing packages to the latest versions.
- Open a terminal and run the following command to update your system:
sudo apt update && sudo apt upgrade -y
- Once the update and upgrade are complete, reboot your system if necessary:
sudo reboot
Step 2: Install Required Packages
You’ll need to install some packages that allow apt
to use packages over HTTPS.
- Run the following command to install the necessary dependencies:
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
Step 3: Add Docker’s Official GPG Key
- Import Docker’s GPG key using
curl
:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Step 4: Add Docker’s Official APT Repository
- Add the Docker repository to your
sources.list.d
directory:
echo "deb [arch=$(dpkg --print-architecture) 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
- Update the package index to include Docker’s repository:
sudo apt update
Step 5: Install Docker Engine
- To install Docker Engine, run the following command:
sudo apt install docker-ce docker-ce-cli containerd.io -y
- Once the installation is complete, check the status of the Docker service:
sudo systemctl status docker
You should see that Docker is active and running. To stop or start the service in the future, use:
sudo systemctl start docker
sudo systemctl stop docker
Step 6: Verify Docker Installation
- Check the installed version of Docker:
docker --version
- Run a test container to ensure Docker is functioning correctly:
sudo docker run hello-world
If everything is set up properly, you’ll see a message from the Docker Engine confirming that the installation is successful.
Step 7: Manage Docker as a Non-Root User (Optional)
By default, the Docker command can only be run by the root user or by a user in the docker
group. To avoid using sudo
with every Docker command, you can add your user to the docker
group.
- Add your user to the
docker
group:
sudo usermod -aG docker $USER
- To apply the group changes, either log out and log back in or run:
newgrp docker
- Verify that you can run Docker commands without
sudo
:
docker run hello-world
Step 8: Enable Docker to Start on Boot
- To ensure Docker starts automatically at boot, run:
sudo systemctl enable docker
Conclusion
Congratulations! You have successfully installed Docker on your Debian 12 system. You’re now ready to start using Docker to deploy and manage containerized applications. For more information on how to use Docker, refer to the official Docker documentation.
Happy containerizing!