How to Install Docker on Debian 13

How to install Docker on Debian 13

Docker is an open-source platform that enables you to build, deploy, and manage applications within lightweight, portable containers. When using Docker on Debian 13, it simplifies software distribution by packaging applications with all their dependencies, ensuring consistency across development, testing, and production environments.

In this tutorial, we’ll guide you through the process of installing and setting up Docker on Debian 13, giving you a reliable foundation for containerized application development and deployment.

Prerequisites:

  • A Debian 13 VPS
  • At least 2 GB of RAM
  • SSH root access or a system user with sudo privileges

Step 1. Update System Packages

To start, log in to your Debian 13 VPS using SSH:

ssh root@IP_Address -p Port_number

Replace ‘IP_Address’ and ‘Port_number’ with your server’s actual IP address and SSH port number. If needed, replace ‘root’ with the username of your sudo account.

Once logged in, ensure that all Debian OS packages installed on the server are up to date. You can do this by running the following commands, a crucial step before working with Docker on Debian 13.

apt update -y && apt upgrade -y

Step 1: Dependencies

The simplest and most straightforward way to install Docker is through Debian’s default package repository.

Use the following command to install dependencies from the Docker repository, as you’ll need these for Docker on Debian 13.

apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y

Step 2: Adding the Docker Repository

Since our dependencies are installed, we’ll proceed with adding the Docker Repository so we can fetch our download. First of all, run the following command to add the GPG Key:

sudo install -m 0755 -d /etc/apt/keyrings
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

Then, we’ll add the Docker repository using this command:

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

You should now run a new update & upgrade on your system to update everything:

apt update -y && apt upgrade -y

Now, we are ready to install Docker.

Step 3: Installing Docker

If you have previously installed Docker on your system from the Debian repository, run the following command to remove the services. If you don’t, you can skip to the next command:

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done

Now we can finally run our Docker installation with this command. Docker on Debian 13 is now becoming a reality on your system.

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

When your installation is complete, you can verify the Docker service with the following commands:

sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.

Step 4: Allowing a Non-root user to use Docker

By default, Docker can only be run by the root user. In this step, we’ll configure a non-root user to run Docker containers by adding the user to the Docker group.

In this example, we will use a test user named john to run Docker containers.

To create the new user john on your Debian system, use the following command:

useradd -m -s /bin/bash -G docker john

With the above command, our user will be created and assigned to the Docker group.

We can now check by accessing the user with the command below:

su - john

And then we’ll run the Hello World Docker

docker run hello-world

And we are done. You have successfully installed Docker on your Debian 13 and learned how to set a non-root user to run Docker containers. For additional details about Docker, its features, and configuration, refer to their official documentation.

Of course, you don’t have to install Docker on Debian 13 if you use one of our Debian VPS Hosting services, in which case you can simply ask our expert Linux admins to install and configure Docker on Debian 13 for you. They are available 24×7 and will take care of your request immediately.

Finally, if you liked this post, please share it with your friends or leave a comment below.

Leave a Comment