What is Docker and Containers - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Monday 13 January 2020

What is Docker and Containers

What is Docker(Dictionary Meaning)

A person employed in a port to load and unload ships.

With Containers we can spin up the applications very fast.


Containers doesn't require HyperVisor and they require OS

Docker is a Container Platform

Virtualization is cumbersome, it needs more resources, hard disk, they are slow

As you can see in the Diagram, in VMs we need to allocate resources from the OS like if you have 9 GB ram , you will be required to allocate 3GB ram to one OS.

While In Docker resources are dynamically allocated based on how many containers are getting used, if 1 Container is running resources would be allocated to that container only

So in Short Virtualization is a technique of  importing Guest OS on top of Host Operating System

While in containers there is no Guest OS Resources and containers only Utilize your Host OS  when needed

Containers are lightweight and faster than VMs

Docker provides containerization platform for all of us to Build--->Run--->Ship a software from Development environment to production environment with so much of ease.

Docker provides its own images which you can deploy and spin up Apps in seconds.

For example if you need to Install ubuntu it can take time.
But with Docker you can install Ubuntu is seconds




Docker Client--> UI for us to enter command.
Docker client connects with help of APIs to Docker Host(residing in cloud)

So in Containerization we have very important component called DAEMON

DAEMON--> It runs everything that an OS may need, it runs, Disk Manager, a network, to make it fast it uses API instead of UI

Registry--> Database , where Docker Stubs resides

Image

Saved Instance
where we save our work and share


Containers
Whenever we create a container, it will be blank and have nothing, so in order to run application we need OS, Java, Selenium, Browsers etc installed in containers,
We use image to setup the containers
So container is just a running instance and they are created from Image

DockerFile
Its a file where you write the instructions to build a Docker Image

Example
all commands like Give me Java, Give me selenium , Give me firefox etc.

We have Docker Hub which has lots of images


https://hub.docker.com/

Whatever Image we have we can keep those images in Docker hub, its similar what we have for Maven as maven repository

Best part of Docker Hub is you can share your image with anyone, so that anyone who uses your image are on the same page and you don't face environmental issues

How does Command works in Docker

Setup Docker QuickStart Terminal

Make sure you have powershell

Download Docker Desktop, Start it, run Powershell
Under Powershell

Run

docker version




Above image shows the steps Docker follows when you run and image from docker hub

How To Run Image

first step is always "pull" the image
second step is to "run" the image

Commands
docker ps-> it shows the containers running
docker images--> show all images in system

docker run -d (this means we are telling docker to run container in background)

For selenium we write

docker run -d  -p 4444:4444 (here we know we use port 4444 to run locally selenium test cases, now we use :4444, to tell run our test cases from local port 4444  and redirect that traffic to 4444 port of containers) 

Below link for all possible commands for Docker

https://www.learnitguide.net/2018/06/docker-images-explained-with-examples.html?m=1


Docker Cheat Sheet



No comments:

Post a Comment