Why it is so popular and when to use it?

Docker Logo

What is Docker?

Docker is a platform for building, running, and shipping applications in a consistent manner. So if you are a developer and your application works perfectly in your development machine, it can run and function the same way on other machines.

  • Software version mismatch.
  • Different configuration settings.

Docker Architecture

Docker Architecture

The Docker client

  • The Docker client (docker) is the primary way that many Docker users interact with Docker. When you use commands such as docker run, the client sends these commands to dockerd, which carries them out. The docker command uses the Docker API. The Docker client can communicate with more than one daemon.

The Docker daemon

  • The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.

Docker registries

  • A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default. You can even run your own private registry.
  • When you use the docker pull or docker run commands, the required images are pulled from your configured registry. When you use the docker push command, your image is pushed to your configured registry.

Who is Docker for?

DevOps

Docker Objects

When you use Docker, you are creating and using images, containers, networks, volumes, plugins, and other objects. This section is a brief overview of some of those objects.

Containers

Dockerfile

Dockerfile is a plain text file that includes the instructions that docker uses to package this application into an Image(more on that in a moment). Each Docker container starts with a Dockerfile. A Dockerfile specifies the operating system that will underlie the container, along with the languages, environmental variables, file locations, network ports, and other components it needs — and, of course, what the container will actually be doing once we run it.

Docker Image

Example of a simple image for a Node.js application:
  • A runtime environment (Eg: Node)
  • Application Files
  • Third-Party Libraries
  • Environment Variables and so on.

Containers vs Virtual Machines

One of the questions that often comes up is how are containers different from Virtual Machines. Do you want to know the differences?

Containers vs VMs

Virtual Machine (VM)

As its name implies, a virtual machine is an abstraction of a machine (Physical Hardware). We can run several virtual machines in one physical machine using a tool called Hypervisor. Hypervisor is basically software used to create and manage virtual machines. Some examples for Hypervisors are Virtual Box, VMware, Hyper-v (Windows only), etc. All the running virtual machines running under the same machine but in different isolated environments.

Problems with Virtual Machine

  • Each VM needs a fully-blown Operating System.
  • Slow to start, because the entire OS has to be loaded just like starting your computer.
  • Resource intensive, because each VM takes a slice of actual physical hardware resources. Like CPU, Memory, and disk space, etc.

Container

Containers give us the same kind of isolation, so we can run multiple applications in isolation.

Docker Installation on Windows

1. Go to the website https://docs.docker.com/docker-for-windows/install/ and download the docker file.

Development Workflow

Now let’s talk about development workflow when using docker.

Devlopment workflow

A Computer Science enthusiast. Software Engineer. Full Stack developer. Music Lover