DEV Community

anjireddy k
anjireddy k

Posted on • Originally published at Medium on

Docker for beginners

VMs vs Containers

Docker got lots of attention these days and DevOps become an integral part of software development. Docker improves the agility of the teams. It became a must for developers as well to run the containers locally

What is Docker?

Docker is a containerization software that allows you to package the application and all its dependencies together as a single unit. It ensures that your application works seamlessly in any environment. The complete package is called a docker container.

Using Docker, you can run multiple operating systems running on the same host which shares the same kernel.

Let say you have an Ubuntu OS with Docker installed on it. Docker can then run any flavor of OS on top of it as long as they are all based on the same kernel, in this case, Linux. Each Docker container has the additional software that makes these OS systems, and Docker utilizes the underlying kernel of Docker host which works with all OS.

So is there an OS that does not share the same kernel as this? Yep. Windows. And that means you can’t run a Windows-based container on a Docker host with Windows OS. For that , you’ll need Docker on a Windows server.

Before going into detail, let us understand what is a container, virtual machine, virtualization, and containerization.

Container: a container is an isolated execution environment where one or more processes can run in isolation.

Each container shares the host OS kernel and, usually, the binaries and libraries. Shared components are read-only. Containers are thus exceptionally “light” -they are only megabytes in size and take just seconds to start, versus gigabytes and minutes for a VM.

Virtual Machine: A virtual machine is a program that acts as a virtual computer. It runs on your current operating system (the host operating system) and provides virtual hardware to guest operating systems. The guest OS runs in a LINUX on your host OS (Windows), just like any other program on your computer.

Virtualization: The process of creating the virtual machines on the fly and running in an isolated environment is known as virtualization

Containerization: The process of creating the containers and running your application as a process inside it; is known as containerization.

The hypervisor allows you to create the VMs on the fly in the servers or local machines.

A hypervisor, or a virtual machine monitor, is software, firmware that creates and runs VMs. It’s what sits between the hardware and the virtual machine and is necessary to virtualize the server.

Difference between VM and Container

The primary difference between the Virtual Machine and Container is that containers provide a way to virtualize an OS so that multiple workloads can run on a single OS instance. With VMs, the hardware is being virtualized to run multiple OS instances.

Docker major components

Docker File

A Dockerfile is a text file that Docker reads in from top to bottom. It contains a bunch of instructions which informs Docker HOW the Docker image should get built.

Docker Engine

Docker engine is a docker application that installed on host machine. It is a client-server type of application which means we have clients who relay to the server. So the Docker daemon called: is the Docker engine which represents the server. The docker daemon and the clients can be run on the same or remote host, and they communicate through command line client binary, as well as a full RESTful API to interact with the daemon: .

Docker Image

An image is an inert, immutable, file that’s essentially a snapshot of a container.

Docker Image is like a template which is used to create Docker Containers. They are the building blocks of a Docker Container. These Docker Images are created using the build command. These Read only templates are used for creating containers by using the run command.

Images are created with the command, and they’ll produce a container when started with .

Docker Registry

Docker stores the images in registries. There are public and private registries. Docker company has public registry called Docker hub, where you can also store images privately.

Docker Container

A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings.

Docker Repository

Docker Repository is a collection of related Docker images, often different versions of the same application.

Docker Compose

Docker compose combines multiple packages into one package. So, you can run this package to bring up all the packages that are listed in the docker compose file at once. this avoids the manual activity of running all the images individually.

In a summary:

  • A Dockerfile is a text file used for creating Docker images
  • A Docker image gets built by running a Docker command (which uses that Dockerfile)
  • A Docker container is a running instance of a Docker image

Docker Architecture

Below diagram depicts the high-level architecture of the Docker.

It includes 3 major components

Docker Client: Used to trigger docker commands

Docker Host: Responsible to run the docker daemon

Docker registry: Responsible for storing the images

The Docker Daemon running within Docker Host is responsible for the images and containers.

Originally published at http://techmonks.org on July 13, 2019.


Top comments (0)