Jun 1, 2023 5 min read

How to Install and Use Docker on Debian 10 Linux

Install Docker on Debian 10 Linux with our step-by-step tutorial. It enables developers to package their software along with its dependencies.

Install and Use Docker on Debian 10 Linux
Table of Contents

Introduction

Before we begin talking about how to install and use Docker on Debian 10 Linux, let's briefly understand – What is Docker?

Docker is a powerful open-source platform that simplifies the process of creating, deploying, and running applications. It enables developers to package their software along with its dependencies into containers. These containers are lightweight, isolated environments that ensure consistent behaviour across different computing environments.

Docker allows for easy portability, scalability, and faster deployment of applications. With Docker, developers can avoid compatibility issues and streamline the development and deployment workflows. It has gained immense popularity for its ability to simplify software development and enhance the efficiency of managing applications.

In this tutorial, you will learn how to install and use Docker on Debian 10 Linux.

Advantages of Docker

  1. Portability: Docker containers are highly portable, allowing applications to run consistently across different systems and environments.
  2. Scalability: Docker enables easy scaling of applications by quickly creating and deploying additional containers.
  3. Efficiency: With Docker, developers can reduce system resource usage and improve overall efficiency through containerization.
  4. Rapid Deployment: Docker facilitates fast and seamless deployment of applications, reducing downtime and improving time-to-market.
  5. Isolation: Docker containers provide a secure and isolated environment, preventing conflicts between applications and enhancing system stability.

Install Docker on Debian

To install the most recent stable version of Docker from the Docker repositories, follow the steps below:

1) Install the required packages to add a new HTTPS repository:

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg2

2) Use the following curl command to import the repository's GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

The command will return OK if it is successful.

3) Add the stable Docker APT repository to the list of software repositories on your system:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

The name of the Debian distribution will be returned by $(lsb release -cs). That would be buster in this instance.

4) Update the apt package list and install the most recent Docker CE (Community Edition) version:

sudo apt update
sudo apt install docker-ce

5) The Docker service will launch automatically after the installation is finished. To confirm it, type in:

sudo systemctl status docker
Output

● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-07-30 20:52:00 GMT; 1min 11s ago
    Docs: https://docs.docker.com
...

6) As of the time of writing, the most recent stable version of Docker is 19.03.1:

docker -v
Output

Docker version 19.03.1, build 74b1e89

Executing the Docker Command Without sudo

Only root and users with sudo privileges can run Docker commands by default.

You must add your user to the docker group that is generated during the installation of the Docker CE package if you wish to run Docker commands without prepending sudo. You can do that by typing:

sudo usermod -aG docker $USER

The environment variable $USER stores your username.

Log out and back in again to update the group membership.

Once finished, type the following to confirm that you can run docker commands without sudo:

sudo docker container run hello-world

The command will download a test image, execute it within a container, print a message saying “Hello from Docker,” and then exit. The output should seem as follows:

Output

Using Docker

Let us go over the essential Docker concepts and commands now that you have Docker installed on your Debian 10 system.

Docker Images

A Docker image is composed of a series of filesystem layers that each reflect instructions in the image’s Dockerfile that make up an executable software program. An image is an immutable binary file that contains the application together with any additional dependencies, including any libraries, binaries, or instructions required for the application to function.

The majority of Docker images may be found on Docker Hub. It is a cloud-based registry service that is used, among other things, to store Docker images in either a public or private repository.

Use the docker search command to look for an image in the Docker Hub registry. For instance, to look for a Debian image, you would type:

sudo docker search debian

Docker Containers

A container is an instance of an image. A container denotes a runtime for a single application, process, or service.

Although it may not be the best analogy, but if you are a programmer, you may consider a Docker image to be a class and a Docker container to be an instance of that class.

Use the docker container command to manage, launch, stop, and remove containers. The following command, for example, will launch a Docker container based on the Debian image. The image will be downloaded first if you do not have it locally:

docker container run debian

Due to the lack of a long-running process and the absence of any further commands, the Debian container will shut down soon after booting up. The container booted up, executed a blank command, and then exited.

You can interact with the container using the command line by using the switch -it. Launch an interactive container by typing:

docker container run -it debian /bin/bash
Output

root@ee86c8c81b3b:/#

As you can see from the output above, the command prompt changes once the container is started, indicating that you are now operating from inside the container.

Use the following command, to list running Docker containers:

sudo docker container ls

The output will be blank if no containers are running.

Pass it the -a switch to display all containers:

sudo docker container ls -a

Simply copy the container ID (or IDs) and paste them after the container rm command to delete one or more containers:

sudo docker container rm c55680af670c

FAQs to Install Docker on Debian 10 Linux

Can I install Docker without root access on Debian 10 Linux?

By default, Docker requires root access to run. However, you can configure Docker to allow non-root users by adding them to the "docker" group.

How do I start the Docker service on Debian 10 Linux?

After installation, Docker should automatically start as a service. You can verify its status using the command systemctl status docker.

How can I update Docker to the latest version on Debian 10 Linux?

Use the package manager to update Docker. Run sudo apt-get update to refresh the package lists, and then run sudo apt-get upgrade docker-ce to update Docker to the latest version.

Can I use Docker with Debian 10 Linux in a production environment?

Yes, Docker is widely used in production environments. However, it is crucial to follow best practices, such as securing the Docker daemon and regularly updating Docker and its dependencies.

What are the system requirements for installing Docker on Debian 10 Linux?

Docker requires a 64-bit version of Debian 10 with a kernel version of 3.10 or later. Ensure your system meets these requirements before installing Docker.

Are there any known issues or limitations when installing Docker on Debian 10 Linux?

While Docker is generally stable, occasional compatibility issues or conflicts with other software may arise. Refer to Docker's official documentation and community forums for troubleshooting guidance.

Conclusion

Docker installation on Debian 10 is a simple process. For container technology, Docker is the de facto standard, and it is a crucial tool for DevOps engineers and their pipeline for continuous integration and delivery.

Visit the official Docker documentation to learn more about this topic.

If you have any queries, feel free to post a comment below, and we'll be happy to answer them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.