Docker for beginners
Tags: docker
Published: 2020-07-15 09:32:59

---
title: Docker for beginners
published: true
date: 2019-07-13 17:06:29 UTC
tags: docker
canonical_url: 
---

![](https://cdn-images-1.medium.com/max/935/1*8_j8n8DWZECp7m6IZUmGcQ.png)<figcaption>VMs vs Containers</figcaption>

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.

![](https://cdn-images-1.medium.com/max/768/0*A3rotMu8f2mwqoLJ.png)

**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.

![](https://cdn-images-1.medium.com/max/1024/0*CuHUWdENRQlgC0wT.png)

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.

![](https://cdn-images-1.medium.com/max/72/0*TDskFaWoBGshoBa9.png)

_Originally published at_ [_http://techmonks.org_](http://techmonks.org/docker-for-beginners/) _on July 13, 2019._

* * *