This tutorial guides you through the step-by-step process of installing Docker on Debian 12. Docker allows you to build, ship, and run applications in containers.
Step 1: Update the System
Ensure your system is updated to avoid compatibility issues.
- Open a terminal.
- Run the following commands:
apt update
apt upgrade -y
Step 2: Install Required Dependencies
Docker requires some prerequisites to function properly.
- Install necessary packages:
apt install -y ca-certificates curl gnupg lsb-release
Step 3: Add Docker’s Official GPG Key
Add the GPG key for Docker’s repository to ensure secure package installation.
- Create a directory for the GPG key:
mkdir -p /etc/apt/keyrings
- Download and add Docker’s GPG key:
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Step 4: Add the Docker Repository
Set up Docker’s repository for the Debian 12 package manager.
- Add the Docker repository to your sources list:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 5: Installing Docker on Debian 12
Now that the repository is configured, you can install Docker.
- Update the package list:
apt update
- Install Docker Engine, CLI, and Containerd:
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 6: Verify Docker Installation
Ensure Docker is installed correctly by checking its version.
- Verify the installation:
docker --version
Example output: Docker version 24.0.2, build cb74dfc
- Run the Docker Hello World container to test:
If everything is working, you will see a message confirming Docker is installed and operational.
docker run hello-world
Step 7: Manage Docker as a Non-Root User (Optional)
By default, Docker requires root privileges. You can configure it to run without sudo
.
- Add your user to the
docker
group:
usermod -aG docker $USER
- Log out and log back in to apply group changes.
- Test running Docker without
sudo
:
docker run hello-world
Step 8: Enable Docker to Start on Boot
Ensure Docker starts automatically when the system boots.
- Enable Docker:
systemctl enable docker
Conclusion
You have successfully installed Docker on Debian 12. Docker is now ready for use, and you can start building and deploying containerized applications. For further usage instructions, consult the official Docker documentation.
Leave a Reply