If you are a developer, you have heard the word "Docker" at some point in your life. Sometimes you might know what it means, and sometimes you might not. Don't worry if you don't know about this word. I will guide you to learn Docker at a beginner level.

Why we use Docker?.

I will give a simple example to explain this.

Post Images

We first download the setup file when we install the software on our computer. Then, we run the installer. When running this installer, sometimes we get some errors during the installation process. If we get some error, we try to troubleshoot these issues using the internet or another way. Then, we rerun the installer. These kinds of errors happen when we install the software. Then, we want to go through this cycle to troubleshoot the errors. This is an endless process. It feels like we're stuck in a loop. To solve this kind of thing, we can use docker. Docker makes installing and running software easy without worrying about setup or dependencies.

Let's see how to install Docker on your Windows machine.

  1. First, sign up for a docker hub account (https://hub.docker.com/signup).

  2. Then you need to install WSL to your computer. To install WSL, you’ll need to run the installation script. Here’s a step-by-step guide:

  • Open PowerShell.
  • Run the following command: wsl --install

This command will enable all necessary features and install Ubuntu for you. If you encounter any issues or have further questions, please refer to the official documentation for assistance.

  1. For some reason, Windows did not prompt you to create a distribution. Therefore, we need to create that one using the command below.

wsl --install -d Ubuntu

  1. Then navigate the official documentation and download the docker desktop installer file.

Post Images

  1. Then double click the Docker desktop installer file.

  2. After the installation process then launch the docker desktop.

  3. Please Ensure that WSL integration is enabled. To do that Please click the settings icon in the docker desktop. Then choose the resources and then check whether WSL integration is enabled or not.

Post Images

  1. Then open the Distro. You can use the Windows search bar to search your distribution.In my case I used Ubuntu as my distribution.

Post Images

  1. Then run the “docker” command to check that docker is working on your environment. Then you can see some helpful instructions based on the below screenshot.

Post Images

What is docker?

Docker is an Open source platform or ecosystem used to build, run, deploy, and update applications quickly. Docker package applications into standardized containers with everything the application needs to run, including system tools, libraries, runtime, and code.

Post Images

What is Container?

Think about when we want to install Redis on our Windows computer. Sometimes, we can't install Redis because we have a lot of issues that occur when installing Redis. Therefore, we need to think about another solution to fulfill our requirements. Docker can help resolve this problem, and we can use Docker to run Redis.

When we run this command (docker run hellow-world), first, docker CLI reaches the docker hub and downloads the image file. Image is a single file containing all the dependencies and configurations required to run a program. We can use this image to create a container. The container is an instance of the image. Container is a process or a set of processes that have grouping of resources specifically assigned to it. Another way , container is a program that has its own isolated set of hardware resources.

Post Images

Okay, now you have a basic understanding of docker and the container. Let's see how docker works.

docker run hello-world

When running this command, you can see a lot of text on the screen. If you go to the beginning of the command line, you can see text like the below screenshot.

Post Images

When we run the docker run command, first, docker CLI or DOCKER CLIENT (docker client is in charge of taking commands from the user) processes the command and communicates that command to the docker server. First, the docker server checked that, the local server (your personal computer) already had a copy of the Hello World file. The Docker server checks this in the image cache. If that file is not in the image cache, then the docker server checks that file in the docker hub. Docker Hub is a repository of free public images we can download and run on our computers. If that file is there, then the docker server downloads that file and stores it in the image cache. If we want to re-run this file in the future, then we can easily run this without re-download it from the docker hub.

After that process, the docker server creates a container instance using this image. As I previously said, a container is an instance of the image. Its purpose is to run one specific program. After creating the container, then run the single program inside it. This is the process that happens when we run the docker run command.

Post Images

I think now you have a basic understanding of docker and how it works. In the next section I will explain how to run docker commands and the life cycle of containers.