Linux Tactic

Installing and Running Docker on Debian: A Comprehensive Guide

Installing and Using Docker in Debian

If you’re looking to use Docker on your Debian-based system but don’t know where to start, you’ve come to the right place. In this article, you’ll find a comprehensive guide detailing how to install and use Docker on your Debian system without hassle.

Installing Docker on Debian

Default Docker Installation with Older Versions

To install Docker on Debian, you can use the Debian default repositories. However, this approach often results in an older Docker version.

Removing Older Docker Versions

Before installing a newer version, remove the older one by running the following commands in the terminal:

“`

sudo apt-get remove docker docker-engine docker.io containerd runc

“`

Installing Latest Docker Version from Official Repository

For up-to-date releases, use the official Docker repository. To do this, add the GPG keys with the command:

“`

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

“`

Then, add the Docker repository to your apt sources list:

“`

echo “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker-ce.list

“`

After that, update the package index and install the latest Docker version:

“`

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io

“`

Adding GPG Keys

GPG keys are added for verification purposes, confirming that the software comes from a trusted source. The command to add GPG keys is:

“`

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

“`

Adding Official Docker Repository

You also need to add the official Docker repository to your apt sources list. To do that, use the following command:

“`

echo “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker-ce.list

“`

Running Hello World Image in Docker

To ensure Docker is installed correctly, we’ll run a popular Hello World image as a test:

“`

docker run hello-world

“`

Using Docker Without Sudo in Debian

By default, Docker requires root or sudo privileges. However, allowing a non-root user to use Docker is more secure.

Here’s how to set that up:

Creating Docker User Group

The first step is to create a Docker user group:

“`

sudo groupadd docker

“`

Adding User to Docker User Group

Next, you need to add your user to the Docker user group:

“`

sudo usermod -aG docker ${USER}

“`

Activating Changes

Finally, to activate the changes, log out and log back in to the system, and Docker will now work without sudo rights.

Conclusion

In conclusion, Docker is a fantastic platform that can help developers improve their workflow, reduce resource usage, and increase productivity. By following the guidelines outlined above, you can easily install and run Docker on your Debian system, as well as using Docker without root privileges.

In this article, we have provided a comprehensive guide on how to install and use Docker on Debian-based systems. We discussed how to install the latest Docker version from the official repository, add GPG keys, and create a Docker User Group to use Docker without sudo rights.

By following these steps, you can easily improve your workflow and increase productivity as a developer. The main takeaways are to remove older Docker versions, add the official Docker repository, and create a Docker User Group to use Docker securely.

We hope you find this guide helpful as you explore the possibilities of Docker on your Debian-based system.

Popular Posts