A Docker is a platform for developing, shipping, and running container applications. Docker is like installing a virtual machine application on your laptop or server, whether itโs VirtualBox, VMWare, or Xen, so you can test various operating systems or applications on it without putting your laptop or server in danger.
Problem
How to install Docker on the Linux server?
Solution
A. Docker summary
The key differentiator between containers and virtual machines is that virtual machines virtualize an entire machine down to the hardware layers, and containers only virtualize software layers above the operating system level. Take a look at the image below to make the difference between virtual machines and Docker clearer:

The table below shows the comparison between virtual machines and Docker:

Below is a brief explanation of the terms in Docker:
- ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐ฃ๐๐น๐น: Downloads images from Docker Hub if not locally available
- ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐๐๐ถ๐น๐ฑ: Creates a local image using a Dockerfile, enabling custom images
- ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐ฃ๐๐๐ต:Uploads images to Docker Hub, allowing sharing
- ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐ฅ๐๐ป: Takes an image to run a container, useful for starting web servers or other applications
- ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐๐บ๐ฎ๐ด๐ฒ: Read-only templates forming the base of containers, including all application dependencies
- ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐๐น๐ถ๐ฒ๐ป๐: Interacts with Docker, sending instructions to the Docker daemon to execute tasks
- ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ Daemon: Handles all requests, including building, running, and distributing containers
- ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐๐ผ๐ป๐๐ฎ๐ถ๐ป๐ฒ๐ฟ๐: Include everything needed to run an application, such as code, libraries, and configurations
- ๐๐ผ๐ฐ๐ธ๐ฒ๐ฟ ๐ฅ๐ฒ๐ด๐ถ๐๐๐ฟ๐: Stores Docker images, with Docker Hub as a public registry and the option to create private ones
The image below is a picture of how the Docker works:

B. Install Docker
In general, use the command belowย to install Docker on Linux:
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
But after you execute the commands above, there is an error like this when you install it in RockyLinux:
ERROR: Unsupported distribution ‘rocky’
You have to install Docker manually using these commands:
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Or when you install Docker in OpenSUSE, you get an error like this:
ERROR: Unsupported distribution ‘opensuse-leap’
Use the commands below to install Docker in OpenSUSE:
sudo zypper install -y docker docker-compose docker-compose-switch
C. After installing Docker
Use the following command to run Docker:
sudo systemctl restart docker
sudo systemctl enable docker
To see the version of Docker you installed, use the command below:
docker info

D. Test the application in Docker
After that, to see whether Docker is running well on the server, use the command below to run the hello-world container on your server:
docker run hello-world
If you have got the error like the image below:

ERROR: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get “http://%2Fvar%2Frun%2Fdocker.sock/v1.47/info”: dial unix /var/run/docker.sock: connect: permission denied
Then you have to run the below command:
sudo usermod -aG docker $USER
Log out of your server and log in again. After that, you should be able to run the Docker commands like in the image below:

That way, your Docker application is ready to use.
Note
You donโt have to use Docker to create and run containers, but you can use other applications such as podman, buildah, cri-o, etc. However, Docker is the most popular at the moment. Also, the terms and workings of various container applications are almost the same, so if you understand the terms and workings of Docker, then you will also understand the terms and workings of other container applications. To learn about basic commands in Docker, go to this page.
References

