July 12, 2019

Part 1: Docker Interview Questions And Answers

What is Virtualization?
Virtualization is the process of creating a software-based, virtual version. These virtual versions or environments are created from a single physical hardware system.

With the help of Virtualization we can split one system into many different sections which act like separate, distinct individual systems.

What is Hypervisor?
A hypervisor also called Virtual Machine Monitor is a software that makes virtualization possible. The virtual environment created by the hypervisor is called Virtual Machine.

It divides the host system and allocates the resources to each divided virtual environment. We can  have multiple OS on a single host system. There are two types of Hypervisors:
  • Type 1: It’s also called Native Hypervisor or Bare metal Hypervisor. It runs directly on the underlying host system. It has direct access to your host’s system hardware and hence does not require a base server operating system.
  • Type 2: It is also known as Hosted Hypervisor and this kind of hypervisor makes use of the underlying host operating system.
What is Containerization?
Sometimes, the code developed on one machine might not work perfectly fine on any other machine because of the dependencies. This problem was solved by the containerization concept.

It is an application that is being developed and deployed is bundled and wrapped together with all its configuration files and dependencies. This bundle is called a container. Most famous containerization environments are Docker and Kubernetes.

What is the difference between Virtualization and Containerization?
Containers provide an isolated environment for running the application. The entire user space is explicitly dedicated to the application. Any changes made inside the container is never reflected on the host or even other containers running on the same host. Containers are an abstraction of the application layer. Each container is a different application.

Whereas in Virtualization, hypervisors provide an entire virtual machine to the guest(including Kernal). Virtual machines are an abstraction of the hardware layer. Each VM is a physical machine.

What is Docker?
Docker is a containerization platform which packages our application and all its dependencies together in the form of containers so as to ensure that our application works seamlessly in any environment, be it development, test or production.

Docker containers, wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries, etc. It wraps basically anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.

What is the difference between Docker and virtual machine?
  • Containers are light weight alternatives of Virtual Machine.
  • Docker containers use host operating system, where as VM's use guest operating system.
  • Unlike VM's, we don't need to pre-allocate any RAM in containers.
  • Every virtual machine runs its OS while Docker containers share the same kernel of the host.
  • Virtual machines boot in minutes while containers take only a few seconds to initiate.
  • An average laptop cannot run more than a couple of VMs. However, the same laptop could run many docker containers.
  • You would not find many VM snapshots. On the other hand, images or snapshots are created one over others in the form of layers.
  • One set of VMDK or VMx files could be used for starting only one VM. In the case of Docker, one docker image can be used for starting multiple docker containers.
What are Docker Images?
Docker Images are read only templates used to create Docker containers. When we run a Docker image, an instance of a container is created.

They are build by Docker user and are stored in Docker Hub or our local registry.

What is a Docker Container?
Docker containers are basically run time instances of Docker Image.

Containers are the basic software unit that stores the code and related dependencies. They help in smooth, quick and reliable deployment of applications from one computing landscape to another.

They shares the kernel with other containers, running as isolated processes in user space on the host operating system.

Containers are created with the help of a Docker image. They have every element needed for running an application such as system tools, runtime, libraries, settings, and code.

What is Docker Hub?
Docker Hub is a GIT repository where the docker images are saved. Users can pick up images from Docker Hub and use them to create customized images and containers.

Explain Registries?
There are two types of registry: Private Registry and Public Registry.

What is a Dockerfile?
Dockerfile is a text document, which contains all the commands a user could call on the command line to assemble an image.

Docker build images automatically by reading the instructions from this file.

What is Docker Compose?
By using docker-compose, you can run multiple containers using a single service. All dockers compose files uses yaml language.

Docker Compose is a YAML file which contains details about the services, networks, and volumes for setting up the Docker application.

We can use Docker Compose to create separate containers, host them and get them to communicate with each other. Each container will expose a port for communicating with other containers.

What is Docker Swarm?
Docker swarm is the native tool designed for clustering and scheduling of Docker containers. It turns a pool of Docker hosts into a single, virtual Docker host.

Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.

What is Docker Machine?
Docker machine is a tool that lets you install Docker Engine on virtual hosts. These hosts can now be managed using the docker-machine commands.

Docker machine also lets you provision Docker Swarm Clusters.

What is the memory swap flag?
Memory swap is a changed flag that only has meaning if memory is also set. Swap allows the container to write express memory requirements to disk when the container has exhausted the entire RAM which is available to it.

What is the lifecycle of a Docker Container?
  • Create a container
  • Run the container
  • Pause the container(optional)
  • Un-pause the container(optional)
  • Start the container
  • Stop the container
  • Restart the container
  • Kill the container
  • Destroy the container
Will you lose your data, when a docker container exists?
No, you won’t lose any data when Docker container exits. Any data that your application writes to the container gets preserved on the disk until you explicitly delete the container. The file system for the container persists even after the container halts.

What are Docker object labels?
Labels are the mechanism for applying metadata to Docker objects such as containers, images, local daemons, networks, volumes, and nodes.

How do Docker daemon and the Docker client communicate with each other?
By combination of Rest API, socket.IO, and TCP to facilitate communication.

Can you implement continuous development (CD) and continuous integration (CI) in Docker?
Yes. We can run Jenkins on Docker and use Docker Compose to run integration tests.

Which factors determine the number of containers you can run?
Even though there is no limit of containers that can run on Docker, hardware limitations come into the picture. Therefore, the two factors which can restrict the number of containers that can be run are related to hardware. They are CPU strength and size of the application.

-K Himaanshu Shuklaa..

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete