Docker Introduction and Its Installation Steps

What is Docker?

Docker is a tool or we can say an open-source platform that helps build, deploy, run, and manage applications and helps package an application with all its dependencies together in a container. It is the most popular tool for containerization of your applications. It helps you to deliver your software quickly by separating your application from your infrastructure and running on a container.

Docker provides you with a loosely isolated environment so that you can, package and run your application smoothly. You can run many containers simultaneously on a single host.

How does Docker Work?

Docker follows a client-server model in its architecture. At its core, there are two key components: the Docker client and the Docker daemon. These components collaborate to handle tasks such as container creation, execution, and distribution. They can be situated on the same machine, or you can configure a Docker client to interact remotely with a Docker daemon.

Communication between the Docker client and daemon takes place via a REST API, utilizing either UNIX sockets for local communication or a network interface for remote interaction. In addition to the Docker client, there is another tool called Docker Compose, which facilitates the management of applications composed of multiple containers.

  • The Docker daemon is always on the lookout for instructions from the Docker API, which is like its phone line for receiving commands. It manages important things in the Docker world like images, containers, networks, and volumes. But here’s the cool part: The Docker daemon can talk with other daemons when needed.
  • The Docker client, which is commonly called “docker,” is like the main control panel for most people using Docker. When you tell it to do something, like running a container with the command “docker run,” it sends those instructions to the Docker daemon, which is like the worker behind the scenes. This Docker daemon then carries out the actual work. Think of the Docker client as the one who talks to you, and the Docker daemon as the one who does the heavy lifting. They communicate using something called the Docker API, which is like their language.
  • Think of a Docker registry as a big digital library where you can find special software packages called “Docker images.”

Install Docker

You can install docker on different platforms they all have different methods of installation

  • Linux
  • mac
  • window

Install docker on Linux

When it comes to installing Docker on a Linux system, you have two primary methods based on your distribution: the Debian method and the RPM method. These methods cater to Debian-based and Red Hat-based distributions, respectively.

  • Install docker for Debian

Debian-based Linux distributions, such as Ubuntu, offer several methods to install Docker. Each method has its own characteristics, and the choice depends on factors like system requirements, preferences, and use cases. Here are some of the main methods for installing Docker on Debian-based systems.

Install Docker from the apt repository

sudo apt-get update 
sudo apt-get install docker.io

Install Docker from the Package

  1. Go to https://download.docker.com/linux/debian/dists/
  2. Select the Debian version in the list you want to download
  3. Download the following deb files for the Docker
  • containerd.io_<version>_<arch>.deb
  • docker-ce_<version>_<arch>.deb
  • docker-ce-cli_<version>_<arch>.deb
  • docker-buildx-plugin_<version>_<arch>.deb
  • docker-compose-plugin_<version>_<arch>.de
  1. install the .deb, Go to the location where you downloaded the Docker packages, and run the command.
sudo dpkg -i ./containerd.io_<version>_<arch>.deb \
  ./docker-ce_<version>_<arch>.deb \
  ./docker-ce-cli_<version>_<arch>.deb \
  ./docker-buildx-plugin_<version>_<arch>.deb \
  ./docker-compose-plugin_<version>_<arch>.deb

Docker Daemon will start automatically.

To check that the docker daemon installs successfully, you can run the Hello-World image.

sudo service docker start
sudo docker run hello-world

Install docker for RPM

RPM-based Linux distributions, such as CentOS and Fedora, offer various methods to install Docker. These methods follow different use cases and user preferences. Here are some of the primary methods for installing Docker on RPM-based systems.

Install docker using the rpm repository.

Sudo yum update
sudo yum install docker.x86_64

Install docker from the package.

Go to the Docker official repository for CentOS and other RPM-based distributions by navigating to the following URL in your web browser: https://download.docker.com/linux/.

Choose the version of rpm that corresponds to your system. You’ll see directories like ‘7’ or ‘8’ for CentOS 7 or CentOS 8, and also for other rpm-based OS respectively. Click on the directory that matches your version.

Click on the .rpm file for the Docker version you’ve chosen. Your web browser will typically prompt you to download the file. Save it to your local machine.

Once you have downloaded the Docker .rpm file, you can proceed to install Docker on your system using the package manager, typically with a command, replacing <version> with the actual version you downloaded.

sudo yum install docker-ce-<version>.rpm, 

To check if the docker daemon is installed successfully, you can run the Hello-World image.

sudo systemctl start docker
sudo docker run hello-world

Install Docker on Mac

When it comes to installing Docker on macOS, you have two main methods: Interactive Installation and Command Line Interface (CLI) Installation. Each method serves a specific purpose and offers distinct advantages.

Install Docker Interactively

  1. The first step is to download the Docker.dmg file, Locate the downloaded Docker.dmg file, and double-click it. This action opens the Docker installer, showing you its contents.
  2. You’ll see the Docker icon inside the installer window. To install Docker on your macOS system, simply drag this Docker icon and drop it into your Applications folder. This process effectively installs Docker on your computer.
  3. Now that Docker is installed, go to your Applications folder. Inside this folder, find the Docker.app icon. To start Docker, double-click on Docker.app. This action launches the Docker application.
  4. When Docker starts, you’ll notice the Docker menu, and you may encounter the Docker Subscription Service Agreement. This agreement outlines the terms and conditions for using Docker. Carefully review the agreement, click the “Accept” button to proceed.
  5. During the installation of Docker Desktop on macOS, you have the option to choose between two configuration modes: “Use recommended settings” or “Use advanced settings.” These settings allow you to customize the Docker Desktop according to your requirements.
  6. After you’ve made your configuration choices during the Docker Desktop installation on macOS, you’ll proceed to the final step.

Install Docker from the command line

To install Docker Desktop on macOS using terminal commands instead of the graphical interface, you can follow these commands. After downloading Docker.dmg run commands to install in Application Folder:

sudo hdiutil attach Docker.dmg
sudo /Volumes/Docker/Docker.app/Contents/MacOS/install
sudo hdiutil detach /Volumes/Docker

Install Docker on Windows

  • To install Docker on Windows, you can use Docker Desktop, which provides an easy way to run Docker containers on Windows. Docker Desktop includes the Docker Engine, Docker CLI, and Docker Compose. Here are the steps to install Docker on Windows:
  • Make sure you have a 64-bit version of Windows 10 or later with Hyper-V and Windows Subsystem for Linux (WSL) 2 support. These features are required to run Docker containers.

Enable Hyper-v and WSL feature

  • To check if WSL or Hyper-v is enabled on your system, go to the search bar. Search for the turn window feature on and add off, check for Hyper- and WSL features if enabled, then move to the next step otherwise, enable Hyper-v and WSL features on your system, and restart your system.
  • Check whether the feature is installed or not. Go to the terminal and type WSL –version to check the version. It should be on version 2.

Install Docker Interactively

  • Download and Install Docker Desktop:
  • Run the installer/.exe file.
  • Run the Docker installer and follow the instructions.
  • If asked to authorize the installer, click “Yes” or “Authorize.”     
  • Once it’s done, click “Close” to finish the installation.

Install from Command Line

  1. After downloading “Docker Desktop Installer.exe,” open a terminal and run the following command in the terminal:

If you’re using Terminal you should run the command:

"Docker Desktop Installer.exe" install

If you’re using PowerShell you should run the command:

"Docker Desktop Installer.exe" install

If using the Windows Command Prompt run the command:

start /w "" "Docker Desktop Installer.exe" install

How to run Docker Commands without using Sudo

  • The first step is to add a user to the docker group if by default docker group is not present on your system, create a group named docker
$ sudo groupadd docker

next step is to add a user to that group $USER exchange this with your username.

$ sudo gpasswd -a $USER docker

Restart the docker Daemon

$ sudo service docker restart
# if you are using docker on ubuntu then run the below command
$ sudo service docker$ sudo service docker restart restart

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top