How to Install Docker in Debian 12 Server Using Docker Apt RepositoryDocker 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:

  1. 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

Update Debian 12 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

Install Dependencies Docker

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

Add Docker’s Official GPG Key

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

Set Up Docker Repository

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

Install the Docker packages

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.

Verify Docker Installation

To check Docker version, run the following command:

sudo docker --version

Check 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

Start and Enable Docker Service

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.

Leave a Reply

Your email address will not be published. Required fields are marked *