In this tutorial, we will guide you through the process of installing Docker on Debian 12. Docker is a powerful container engine that enables you to create, deploy, and run applications efficiently. By utilizing the Linux Kernel, Docker allows you to create containers on top of an operating system, providing a lightweight and isolated environment for your applications.

Prerequisites

Before we begin, make sure you have the following prerequisites in place:

  • A server running Debian 12
  • SSH access to the server with administrative privileges

Step 1: Updating the System

The first step is to update the system to ensure that you have the latest packages and dependencies. Open your terminal and connect to your server via SSH. Once connected, run the following command to update the system:

sudo apt update && sudo apt upgrade

This command will update the package lists and upgrade the installed packages to their latest versions.

Step 2: Installing Docker

To install Docker on Debian 12, we will use the apt package manager. Run the following command to install Docker:

sudo apt install docker.io docker-compose

This command will install both Docker and Docker Compose, a tool for defining and running multi-container Docker applications.

Step 3: Starting and Enabling Docker

After the installation is complete, start the Docker service and enable it to start automatically on system boot. Run the following command:

sudo systemctl enable --now docker

This command will start the Docker service and configure it to start at boot time.

You can verify the status of the Docker service by running the following command:

sudo systemctl status docker

If Docker is running correctly, you should see an output similar to this:

● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled)
Active: active (running) since Tue 2023-06-13 16:20:51 UTC; 20s ago
Docs: https://docs.docker.com
Main PID: 5345 (dockerd)
Tasks: 8
Memory: 28.0M
CPU: 930ms
CGroup: /system.slice/docker.service
└─5345 /usr/sbin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Step 4: Creating a Docker User Group

To allow non-root users to run Docker commands, we need to create a group called “docker” and add the desired user to that group. Run the following command to create the group:

sudo groupadd docker

To add a user to the “docker” group, replace $USER with the username of the user. Run the following command:

sudo usermod -aG docker $USER

Now, the user will have the necessary permissions to run Docker commands without using sudo.

Step 5: Verifying the Docker Installation

To verify that Docker has been installed correctly, you can check the version of Docker by running the following command:

docker --version

If Docker is installed properly, you should see an output similar to this:

Docker version 20.10.24+dfsg1, build 297e128

Step 6: Testing Docker with a Sample Container

To test Docker, we will run a “hello-world” container. Run the following command:

docker run hello-world

If Docker is functioning correctly, you should see the following output:

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

Congratulations! You have successfully installed Docker on Debian 12 and verified its functionality.

Conclusion

In this tutorial, we walked you through the process of installing Docker on Debian 12. We covered the installation steps, starting and enabling the Docker service, creating a Docker user group, and verifying the installation with a sample container. Docker provides a powerful and efficient way to create, deploy, and run applications in isolated containers.

By leveraging Docker, you can optimize resource utilization and streamline your application deployment process. Whether you are a developer or a system administrator, Docker can greatly simplify application management and improve scalability.

To further enhance your Docker experience, consider exploring Shape.host’s Linux SSD VPS services. With Shape.host, you can leverage their reliable and scalable cloud hosting solutions to maximize the benefits of Docker in your environment.

For more information and ideas, visit Shape.host today!