Docker is a popular platform for developing, shipping, and running applications inside containers. Installing Docker on a Debian 12 server is a straightforward process.
In this guide, I will walk you through the steps to install Docker on your Debian 12 server.
Prerequisites
Before you begin, make sure you have the following:
- A Debian 12 server with root access or a user with sudo privileges. Check out RackNerd and Contabo VPS.
Step 1: Update System Packages
Before installing Docker, it’s a good practice to update your system’s package repository to ensure you have the latest versions of packages.
You can use an SSH client to login to your server.
For root users, use the following command:
apt update && apt -y upgrade && apt -y install sudo
For non-root users, use the following command:
sudo apt update && sudo apt upgrade
Step 2: Install Dependencies
Docker requires some dependencies to be installed. You can do this by running the following command:
sudo apt-get update sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings
Step 3: Add Docker’s Official GPG Key
To ensure the integrity of the downloaded Docker packages, 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
Step 4: Set Up Docker Repository
Add the Docker repository to your system’s software sources:
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
Step 5: Install Docker Engine
Once the repository is added, update the package index again and install the Docker Engine:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 6: Verify Docker Installation
After installation, verify that Docker Engine is installed correctly by running the following command:
sudo docker run hello-world
If Docker is set up correctly, you should see a message indicating that your installation is working.
To check Docker version, run the following command:
sudo docker --version
Step 7: Start and Enable Docker Service
Start the Docker service and enable it to start on boot:
sudo systemctl start docker sudo systemctl enable docker
Conclusion
Congratulations! You have successfully installed Docker on your Debian 12 Server using the Docker apt repository. You can now start using Docker to deploy and manage containers on your system.