How to install docker in the right way to GNU/Linux

How to install docker in the right way to GNU/Linux
Source - Photo by Ian Taylor on Unsplash

Introduction

Docker is a software platform that allows developers to create, deploy, and run applications in containers. Containers are a lightweight and portable way of packaging software and its dependencies, allowing applications to run consistently across different environments, from development to production.

With Docker, developers can build container images that contain all the necessary software components and configurations for their application to run. These images can be easily shared and deployed to any environment that supports Docker.

Docker Compose is a tool for defining and running multi-container Docker applications. With Docker Compose, developers can define a multi-container application using a YAML file, which specifies the containers, their configurations, and how they interact with each other. Docker Compose simplifies the process of managing multiple containers and their dependencies, making it easier to develop and deploy complex applications.

Using Docker and Docker Compose, developers can create and deploy applications that are portable, scalable, and easy to manage, reducing the time and effort required to build and deploy software.

You will going to learn following things in this tutorial.

  1. Installing docker 🐟.
  2. Installing docker-compose.
  3. Post-installation steps for docker.
Source - link

Installing docker 🐟

First, check for the updates by typing

sudo apt update

Now type

sudo apt install docker.io

This will ask yes or no. Select yes to continue with the installation.

And you are done with the docker installation.

Installing docker-compose🐟

sudo apt install docker-compose

select yes to continue with the installation.

And you are done.

Post-installation steps for docker

This is I think important step for installing docker properly. Which most of us miss out on while installing docker.

My senior told me that Orendra go and search. Post-installation steps for docker and click. On the first link to follow the steps. That will help you install your docker always properly.

If he would have directly told me the commands. I would have forgotten that very easily but this way I still remember.

So you may also give it a try go and search post-installation steps for docker.

But you can also directly click on this link. Or follow the below guide to follow the post-installation steps.

So basically this step involved allowing docker to run without using sudo every time. And allow docker to run using your user group.

To create the docker group and add your user:

Create the docker group.

sudo groupadd docker

Add your user to the docker group.

sudo usermod -aG docker $USER

Log out and log back in so that your group membership is re-evaluated.

If you’re running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.

You can also run the following command to activate the changes to groups:

newgrp docker

Verify that you can run docker commands without sudo

docker run hello-world

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

Configure Docker to start on boot with systemd

Source - https://pin.it/5JjPBSF

Many modern Linux distributions use systemd to manage which services start when the system boots. On Debian and Ubuntu, the Docker service starts on boot by default. To automatically start Docker and containerd on boot for other Linux distributions using systemd, run the following commands:

sudo systemctl enable docker.service
sudo systemctl enable containerd.service

To disable, use disable.

sudo systemctl disable docker.service
sudo systemctl disable containerd.service

I hope you loved reading this article. And might get to learn something new.

If you see any improvements let me know in the comments section.

Thanks