Showing posts with label DevOps. Show all posts
Showing posts with label DevOps. Show all posts

Kubernetes Interview Question Set -2

Q1. Define kubelet

The kubelet is a service agent which controls and maintains a group of pods by checking pod specifications using Kubernetes. The kubelet runs on each node and allows communication between a master node and a slave node.

Q2 What are the disadvantages of Kubernetes?

Kubernetes dashboard is not as helpful as it should be

Security is not very effective.

It is very complex and can reduce productivity

Kubernetes is more costly than its alternatives.

Q3. What is Kube-proxy?

Kube-proxy is an implementation of both a network proxy and a load balancer. It is used to support service abstraction used with other networking operations. It is responsible for directing traffic to the container depending on IP and the port number.

Q4. What is the role of Load Balance in Kubernetes?

Load balancing is a way to distribute the incoming traffic into multiple backend servers, which is useful to ensure the application available to the users.



In Kubernetes, as shown in the above figure all the incoming traffic lands at a single IP address on the load balancer which is a way to expose your service to outside the internet and route the incoming traffic to a particular pod (via service) using an algorithm known as round-robin. Even if any pod goes down load balances are notified so that the traffic is not routed to that particular unavailable node.  Thus load balancers in Kubernetes are responsible for distributing a set of tasks (incoming traffic) to the pods.

Q5. How to monitor the Kubernetes cluster?

Prometheus is used for Kubernetes monitoring. The Prometheus ecosystem consists of multiple components.

1. Mainly Prometheus server which scrapes and stores time-series data.

2. Client libraries for instrumenting application code.

3. Push gateway for supporting short-lived jobs.

4. Special-purpose exporters for services like StatsD, HAProxy, Graphite, etc.

5. An alert manager to handle alerts on various support tools

Q6. How to get the central logs from POD?

This architecture depends upon the application and many other factors. Following are the common logging patterns.

Node-level logging agent.

Streaming sidecar container.

Sidecar container with the logging agent.

Export logs directly from the application.

In the setup, journal beat and file beat are running as daemon sets. Logs collected by these are dumped to the Kafka topic which is eventually dumped to the ELK stack.

Q7. What is the difference between Kubernetes and Docker Swarm?

The difference between Kubernetes and Docker Swarm is:

KubernetesDocker Swarm
Kubernetes provides an auto-scaling feature.Docker Swarm does not provide an auto-scaling feature.
Manually configure your load balancing settings. Does auto load balancing
Installation is complicated & time-consuming.Installation is easy & fast.
GUI is available.GUI is not available.
It provides a built-in load-balancing technique.Process scheduling is done to maintain services while updating.

Q8. Define Ingress Network

Ingress network is defined as a collection of rules which allow permission for connections into the Kubernetes cluster.

Q9. How to configure TLS with Ingress?

Add tls and secretName entries.

spec:

  tls:

   - hosts:

       - exampleapp.com

             secretName: exampleapp-secret-tls

Q10. What is Kubectl?

Kubectl is the platform using which you can pass commands to the cluster. So, it basically provides the CLI to run commands against the Kubernetes cluster with various ways to create and manage the Kubernetes component.

Q11. What is Google Container Engine?

Google Container Engine (GKE) is an open-source management platform for Docker containers and clusters. This Kubernetes-based engine supports only those clusters which run within Google’s public cloud services.

Q12. Why load balancer is needed?

A load balancer is needed because it gives a standard way to distribute network traffic among different services, which run in the backend.

Q13. How to run Kubernetes locally?

Kubernetes can be run locally using the Minikube tool. It runs a single-node cluster in a VM (virtual machine) on the computer. Therefore, it offers the ideal way for users who have just started learning Kubernetes.

Q14. What are the tools that are used for container monitoring?

Tools that are used for container monitoring are:

Heapster

cAdvisor

Prometheus

InfluxDB

Grafana

Q15. List components of Kubernetes

There are three components of Kubernetes, they are:

Addons

Node components

Master Components

Q16 Define headless service

Headless service is defined as a service that uses an IP address, but instead of load balancing, it returns associated pods.

Q17. What are the important components of node status?

The important component of node status are:

Condition

Capacity

Info

Address

Q18 What is minikube?

Minikube is a tool that makes it easy to run Kubernetes locally. This runs a single-node Kubernetes cluster inside a virtual machine.

Q19. Mention the uses of GKE

The uses of the GKE (Google Kubernetes Engine) are:

It can be used to create docker container clusters

Resize application controllers

Update and then upgrade the clusters of container

Debug cluster of the container.

GKE can be used to create a replication controller, jobs, services, container pods, or load balancers.

Q20. Define orchestration in Kubernetes

Orchestration in Kubernetes defines as an automatic method of scheduling the work of every container. It is used for applications that are based on microservices within clusters.

Q21. Explain Prometheus in Kubernetes

Prometheus is an application that is used for monitoring and alerting. It can be called out to your systems, grab real-time metrics, compress them, and store them properly in a database.

Q22. List tools for container orchestration

The tools for container orchestration are 

1) Docker swarm

2) Apache Mesos

3) Kubernetes.

Q23. Mention the list of objects of Kubernetes?

Objects that are used in Kubernetes are: 

1) Pods

2) Replication sets and controllers

3) Jobs and cron jobs

4) Daemon sets

5) Distinctive identities

6) Deployments

7) Stateful sets.

Q24. Define Stateful sets in Kubernetes

The stateful set is a workload API object that is used to manage the stateful application. It can also be used to manage the deployments and scale the sets of pods. The state information and other data of stateful pods are stored in the disk storage, which connects with the stateful set.

Q25. Why use Daemon sets?

Daemon sets are used because:

It enables to runs storage platforms like ceph and glusterd on each node. Daemon sets run the logs collection on every node such as filebeat or fluentd. It performs node monitoring on each and every node.

Q26. Explain Replica set

A Replica set is used to keep replica pods stable. It enables us to specify the available number of identical pods. This can be considered a replacement for the replication .controller.

Q27. List out some important Kubectl commands:

The important Kubectl commands are:

kubectl annotate

kubectl cluster-info

kubectl attach

kubectl apply

kubectl config

kubectl autoscale

kubectl config current-context

kubectl config set.

Q28. Why uses Kube-apiserver?

Kube-apiserver is an API server of Kubernetes that is used to configure and validate API objects, which include services, controllers, etc. It provides the front end to the cluster’s shared region using which components interact with each other.

Q29. Explain the types of Kubernetes pods

There are two types of pods in Kubernetes:

Single Container Pod: It can be created with the run command.

Multicontainer pods: These can be created using the “create” command in Kubernetes.

Q30. What are the labels in Kubernetes?

Labels are a collection of keys that contain some values. The key values are connected to pods, replication controllers, and associated services. Generally, labels are added to some object during its creation time. They can be modified by the users at run time.

Q31. Define OpenShift

OpenShift is a public cloud application development and hosting platform developed by Red Hat. It offers automation for management so that developers can focus on writing the code.

Q32. What are federated clusters?

Federated clusters multiple clusters that are managed as a single cluster.

Q33. Mention the difference between Docker volumes and Kubernetes Volumes

Kubernetes Volumes:

1. Volumes are not limited to any container.

2. Kubernetes volumes support all containers deployed in a pod of Kubernetes.

Docker Volumes:

1. Volumes are limited to a pod in the container.

2. Docker volumes do not support all containers deployed in Docker.

Q34. What are the ways to provide API-Security on Kubernetes?

The ways to provide API-Security on Kubernetes are:

Using correct auth mode with API server authentication mode= Node.

Make kube less that protects its API via authorization-mode=Webhook. Ensure the kube-dashboard uses a restrictive RBAC (Role-Based Access Control) policy.

Q35. What is ContainerCreating pod?

A ContainerCreating pod is one that can be scheduled on a node but can’t start up properly.


Kubernetes commands

Exception Handling Interview Questions

DBMS Interview Questions Set -1

DBMS Interview Questions Set -2

SQL Interview Question Set -1

SQL Interview Question Set -2

JPA Interview Questions Set -1

JPA Interview Question Set -2

Hibernate Interview Questions

Spring Boot Interview Questions Set 1

Spring Boot Interview Questions Set 2

GIT Interview Questions

Redis Interview Questions

Core Java Interview Questions Set -1

Docker interview question Set -1

Docker interview question Set -2

Kubernetes Interview Question Set -1

Kubernetes Interview Question Set -2

Collection interview questions

Kafka Interview Questions

Kubernetes Interview Question Set -1

Q1. What is Kubernetes?

Kubernetes is a container management system developed in the Google platform. 

The purpose of Kubernetes is to manage a containerized application in various types of physical, virtual, and cloud environments. Google Kubernetes is a highly flexible container tool to deliver even complex applications, consistently. Applications run on clusters of hundreds to thousands of individual servers.

Q2. What are K8s?

K8s is another term for Kubernetes.

Q3. How is Kubernetes related to Docker?

It’s a known fact that Docker provides the lifecycle management of containers and a Docker image builds the runtime containers. But, since these individual containers have to communicate, Kubernetes is used. So, Docker builds the containers and these containers communicate with each other via Kubernetes. So, containers running on multiple hosts can be manually linked and orchestrated using Kubernetes.

Q4. What is Container Orchestration?

Orchestration refers to the integration of multiple services that allows them to automate processes or synchronize information in a timely fashion. Say, for example, you have six or seven microservices for an application to run. If you place them in separate containers, this would inevitably create obstacles to communication. Orchestration would help in such a situation by enabling all services in individual containers to work seamlessly to accomplish a single goal. 

Q5. How are Kubernetes and Docker related?

Docker is an open-source platform used to handle software development. Its main benefit is that it packages the settings and dependencies that the software/application needs to run into a container, which allows for portability and several other advantages. Kubernetes allows for the manual linking and orchestration of several containers, running on multiple hosts that have been created using Docker. 

Q6. Define node in Kubernetes

A node is the smallest unit of hardware. It defines a single machine in a cluster that can be a virtual machine from a cloud provider or a physical machine in the data center. Every machine available in the Kubernetes cluster can substitute for other machines.

Q7. What are the main differences between the Docker Swarm and Kubernetes?

Docker Swarm is Docker’s native, open-source container orchestration platform that is used to cluster and schedule Docker containers.

Swarm differs from Kubernetes in the following ways:

1. Docker Swarm is more convenient to set up but doesn’t have a robust cluster, while Kubernetes is more complicated to set up but the benefit of having the assurance of a robust cluster.

2. Docker Swarm can’t do auto-scaling (as can Kubernetes); however, Docker scaling is five times faster than Kubernetes.

3. Docker Swarm doesn’t have a GUI; Kubernetes has a GUI in the form of a dashboard.

4. Docker Swarm does automatic load balancing of traffic between containers in a cluster, while Kubernetes requires manual intervention for load balancing such traffic.

5. Docker requires third-party tools like ELK stack for logging and monitoring, while Kubernetes has integrated tools for the same.

6. Docker Swarm can share storage volumes with any container easily, while Kubernetes can only share storage volumes with containers in the same pod.

7. Docker can deploy rolling updates but can’t deploy automatic rollbacks; Kubernetes can deploy rolling updates as well as automatic rollbacks.

Q8. What is the difference between deploying applications on hosts and containers?

Deploying Applications consists of an architecture that has an operating system. The operating system will have a kernel that holds various libraries installed on the operating system needed for an application. Whereas container host refers to the system that runs the containerized processes. This kind is isolated from the other applications; therefore, the applications must have the necessary libraries. The binaries are separated from the rest of the system and cannot infringe any other applications.

Q9. What are the features of Kubernetes?

1. Kubernetes places control on the user where the server will host the container. It will control how to launch. So, Kubernetes automates various manual processes. 

2. Kubernetes manages various clusters at the same time. 

3. It provides various additional services like management of containers, security, networking, and storage.

4. Kubernetes self-monitors the health of nodes and containers.

5. With Kubernetes, users can scale resources not only vertically but also horizontally too easily and quickly.

Q10. What are the main components of Kubernetes architecture?

There are two primary components of Kubernetes Architecture: 

the master node and the worker node. Each of these components has individual components in them.

Q11. Explain the working of the master node in Kubernetes?

The master node dignifies the node that controls and manages the set of worker nodes. This kind resembles a cluster in Kubernetes. The nodes are responsible for cluster management and the API used to configure and manage the resources within the collection. The master nodes of Kubernetes can run with Kubernetes itself, the asset of dedicated pods.

Q12. What is the work of a Kube-scheduler?

Kube-scheduler is the default scheduler for Kubernetes. It assigns nodes to newly created pods.

Q13. What is the role of Kube-apiserver?

This kind validates and provides configuration data for the API objects. It includes pods, services, and replication controllers. Also, it provides REST operations and also the front end of the cluster. This frontend cluster state is shared through which all other component interacts.

Q14. Define daemon sets.

Daemon sets are a set of pods that runs on a host. They are used for host layers attributes like monitoring networks or simple networks.

Q15. What is Heapster?

Heapster is a cluster-wide aggregator of data provided by Kubelet running on each node. This container management tool is supported natively on the Kubernetes cluster and runs as a pod, just like any other pod in the cluster. So, it basically discovers all nodes in the cluster and queries usage information from the Kubernetes nodes in the cluster, via the on-machine Kubernetes agent.

Q16. What tasks are performed by Kubernetes?

Kubernetes is the Linux kernel that is used for distributed systems. It helps you to abstract the underlying hardware of the nodes(servers) and offers a consistent interface for applications that consume the shared pool of resources.

Q17. Define Kubernetes controller manager

The controller manager is a daemon used for garbage collection, core control loops, and namespace creation. It enables the running of more than one process on the master node.

Q18. Mention the types of controller managers

Types of controller managers are: 

1) endpoints controller

2) service accounts controller

3) node controller

4) namespace controller

5) replication controller

6) token controller.

Q19. Why use namespace in Kubernetes?

Namespaces in Kubernetes are used for dividing cluster resources between users. It helps the environment where more than one user spread projects or teams and provides a scope of resources.

Q20. Why use Kubernetes?

Kubernetes is used because:

1. Kubernetes can run on-premises bare metal, OpenStack, public clouds Google, Azure, AWS, etc.

2. It helps you to avoid vendor lock issues as it can use any vendor-specific APIs or services except where Kubernetes provides an abstraction, e.g., load balancer and storage.

3. It will enable applications that need to be released and updated without any downtime.

4. Kubernetes allows you to assure those containerized apps run where and when you want and help you to find resources and tools in which you want to work.

Q21. What are the features of Kubernetes?

The features of Kubernetes are:

1. Automated Scheduling

2. Self-Healing Capabilities

3. Automated rollouts & rollback

4. Horizontal Scaling & Load Balancing

5. Offers environment consistency for development, testing, and production.

6. Infrastructure is loosely coupled to each component and can act as a separate unit.

7. Provides a higher density of resource utilization.

8. Offers enterprise-ready features

9. Application-centric management

10. Auto-scalable infrastructure

11. You can create predictable infrastructure

Q22. Explain Kubernetes Architecture

Kubernetes Architecture Diagram

Master Node: The master node is the first and most vital component which is responsible for the management of the Kubernetes cluster. It is the entry point for all kinds of administrative tasks. There may be more than one master node in the cluster to check for fault tolerance.

API Server: The API server acts as an entry point for all the REST commands used for controlling the cluster.

Scheduler: The scheduler schedules the tasks to the slave node. It stores the resource usage information for every slave node. It is responsible for distributing the workload.

Etcd: etcd components, store configuration detail, and write values. It communicates with the most component to receive commands and work. It also manages network rules and port forwarding activity.

Worker/Slave nodes: Worker nodes are another essential component that contains all the required services to manage the networking between the containers, and communicate with the master node, which allows you to assign resources to the scheduled containers.

Kubelet: It gets the configuration of a Pod from the API server and ensures that the described containers are up and running.

Docker Container: Docker container runs on each of the worker nodes, which runs the configured pods.

Pods: A pod is a combination of single or multiple containers that logically run together on nodes.


Q23. List various services available in Kubernetes

Various services available in Kubernetes are:

1) Cluster IP service

2) Load Balancer service

3) Node Port service

4) External Name Creation service.

Q24. Define Cluster IP

The Cluster IP is a Kubernetes service that offers a service inside the cluster that other apps inside the cluster can access.

Q25. Explain node port

The node port service is a fundamental way to get external traffic to your service. It opens a particular port on all nodes and forwards network traffic sent to this port.

Q26. What are the objectives of the replication controller?

The objectives of the replication controller are:

It is responsible for controlling and administering the pod lifecycle.

It monitors and verifies whether the allowed number of replicas are running or not.

The replication controller helps the user to check the pod status.

It enables to alteration of a pod. The user can drag its position the way interested in it.

Q27. What do you mean by persistent volume?

A persistent volume is a storage unit that is controlled by the administrator. It is used to manage an individual pod in a cluster.

Q28. What are Secrets in Kubernetes?

Secrets are sensitive information like the login credentials of the user. They are objects in Kubernetes that store sensitive information like usernames and passwords after performing encryption.

Q29. What is Sematext Docker Agent?

Sematext Docker agent is a log collection agent with events and metrics. It runs as a small container in each Docker host. These agents gather metrics, events, and logs for all cluster nodes and containers.

Q30. What are the various things that can be done to increase Kubernetes security?

By default, POD can communicate with any other POD, we can set up network policies to limit this communication between the PODs. RBAC (Role-based access control) to narrow down the permissions. Use namespaces to establish security boundaries. Set the admission control policies to avoid running the privileged containers. Turn on audit logging.

Q31. What are the types of Kubernetes Volume?

The types of Kubernetes Volume are:

EmptyDir

GCE persistent disk

Flocker

HostPath

NFS

ISCSI

rbd

PersistentVolumeClaim

downwardAPI

Q32. Explain PVC

The full form of PVC stands for Persistent Volume Claim. It is storage requested by Kubernetes for pods. The user does not require to know the underlying provisioning. This claim should be created in the same namespace where the pod is created.

Q33. What is the Kubernetes Network Policy?

Network Policy defines how the pods in the same namespace would communicate with each other and the network endpoint.

Q34. What is Kubernetes proxy service?

Kubernetes proxy service is a service that runs on the node and helps in making it available to an external host.

Q35. What is Kubernetes Load Balancing?

Load Balancing is one of the most common and standard ways of exposing the services. There are two types of load balancing in K8s and they are:

Internal load balancer – This type of balancer automatically balances loads and allocates the pods with the required incoming load.

External Load Balancer – This type of balancer directs the traffic from the external loads to backend pods.


Kubernetes commands

Exception Handling Interview Questions

DBMS Interview Questions Set -1

DBMS Interview Questions Set -2

SQL Interview Question Set -1

SQL Interview Question Set -2

JPA Interview Questions Set -1

JPA Interview Question Set -2

Hibernate Interview Questions

Spring Boot Interview Questions Set 1

Spring Boot Interview Questions Set 2

GIT Interview Questions

Redis Interview Questions

Core Java Interview Questions Set -1

Docker interview question Set -1

Docker interview question Set -2

Kubernetes Interview Question Set -1

Kubernetes Interview Question Set -2

Collection interview questions

Kafka Interview Questions

Docker Basic Commands

Q1. How to check for Docker Client and Docker Server versions?

$ docker version

Q2. How do you get the number of containers running, paused, and stopped?

$ docker info

Q3. If you vaguely remember the command and you’d like to confirm it, how will you get help on that particular command?

$ docker --help

The above command lists all Docker commands. If you need help with one specific command, you can use the following syntax:

$ docker <command> --help

Q4. How to login into the docker repository?

You can use the following command to login into hub.docker.com:

$ docker login

You’ll be prompted for your username and password, insert those, and congratulations, you’re logged in.

Q5. If you wish to use a base image and make modifications or personalize it, how do you do that?

It’s one simple command to pull an image from docker hub:

$ docker pull <image_name>

Q6. How do you create a docker container from an image?

Pull an image from the docker repository with the above command and run it to create a container. Use the following command:

$ docker run -it -d <image_name>

Most probably the next question would be, what does the ‘-d’ flag mean in the command?

-d means the container needs to start in the detached mode.

Q7. How do you list all the running containers?

The following command lists down all the running containers:

$ docker ps

Q8. Suppose you have 3 containers running and out of these, you wish to access one of them. How do you access a running container?

The following command lets us access a running container:

$ docker exec -it <container id> bash

The exec command lets you get inside a container and work with it.

Q9. How to start, stop and kill a container?

The following command is used to start a docker container:

$ docker start <container_id>

and the following for stopping a running container:

$ docker stop <container_id>

kill a container with the following command:

$ docker kill <container_id>

Q10. Can you use a container, edit it, and update it? Also, how do you make it new and store it on the local system?

Of course, you can use a container, edit it and update it. This sounds complicated but it's actually just one command.

$ docker commit <conatainer id> <username/imagename>

Q11. How do you push it to the docker hub?

$ docker push <username/image name>

Q12. How to delete a stopped container?

Use the following command to delete a stopped container:

$ docker rm <container id>

Q13. How to delete an image from the local storage system?

The following command lets you delete an image from the local system:

$ docker rmi <image-id>

Q14. How to build a Dockerfile?

Once you’ve written a Dockerfile, you need to build it to create an image with those specifications. Use the following command to build a Dockerfile:

$ docker build <path to docker file>

Q15. Do you know why the docker system prune is used? What does it do?

$ docker system prune

The above command is used to remove all the stopped containers, all the networks that are not used, all dangling images, and all build caches. It’s one of the most useful docker commands.

Q16. What command should you run to see all running containers in Docker

$ docker ps

Q17. Write the command to stop the docker container

$ sudo docker stop container name

Q18. What is the command to run the image as a container?

$ sudo docker run -i -t alpine /bin/bash

Q19. What command can you run to export a docker image as an archive?

This can be done using the docker save command and the syntax is: 

docker save -o <exported_name>.tar <container-name>

Q20. What command can be run to import a pre-exported Docker image into another Docker host?

This can be done using the docker load command and the syntax is 

docker load -i <export_image_name>.tar


Docker interview question Set -1

Docker interview question Set -2

Docker interview question Set -2

Q1. How will you ensure that container 1 runs before container 2 while using docker-compose?

Docker-compose does not wait for any container to be “ready” before going ahead with the next containers.

In order to achieve the order of execution, we can use:

The “depends_on” which got added in version 2 of docker-compose can be used as shown in a sample docker-compose.yml file below:

version: "2.4"

services:

backend:

   build: .

   depends_on:

- db

db:

   image: postgres

The introduction of service dependencies has various causes and effects:

The docker-compose-up command starts and runs the services in the dependency order specified. For the above example, the DB container is started before the backend. docker-compose up SERVICE_NAME by default includes the dependencies associated with the service. In the given an example, running docker-compose up backend creates and starts DB (dependency of backend).

Finally, the command docker-compose stop also stops the services in the order of the dependency specified. For the given example, the backend service is stopped before the DB service.

Q2. Will you lose your data, when a docker container exists?

No, you won’t lose any data when the 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.

Q3. Where do you think Docker is being used?

Docker is being used in the following areas:

Simplifying configuration: Docker lets you put your environment and configuration into code and deploy it.

Code Pipeline Management: There are different systems used for development and production. As the code travels from development to testing to production, it goes through a difference in the environment. Docker helps in maintaining the code pipeline consistency.

Developer Productivity: Using Docker for development gives us two things – We’re closer to production and the development environment is built faster.

Application Isolation: As containers are applications wrapped together with all dependencies, your apps are isolated. They can work by themselves on any hardware that supports Docker.

Debugging Capabilities: Docker supports various debugging tools that are not specific to containers but work well with containers.

Multi-tenancy: Docker lets you have multi-tenant applications avoiding redundancy in your codes and deployments.

Rapid Deployment: Docker eliminates the need to boost an entire OS from scratch, reducing the deployment time.

Q4. How is Docker different from other containerization methods?

Docker containers are very easy to deploy in any cloud platform. It can get more applications running on the same hardware when compared to other technologies, it makes it easy for developers to quickly create, ready-to-run containerized applications and it makes managing and deploying applications much easier. You can even share containers with your applications.

If you have some more points to add you can do that but make sure the above explanation is there in your answer.

Q5. Can I use JSON instead of YAML for my compose file in Docker?

You can use JSON instead of YAML for your compose file, to use JSON file with composing, specify the JSON filename to use, for eg:

$ docker-compose -f docker-compose.json up

Q6. Does Docker offer support for IPV6?

Yes, Docker provides support for IPv6. IPv6 networking is supported only on Docker daemons run on Linux hosts. However, if you want to enable IPv6 support in the Docker daemon, you need to modify /etc/docker/daemon.json and set the ipv6 key to true.

Q7. How far do Docker containers scale? Are there any requirements for the same?

Large web deployments like Google and Twitter and platform providers such as Heroku and dotCloud, all run on container technology. Containers can be scaled to hundreds of thousands or even millions of them running in parallel. Talking about requirements, containers require the memory and the OS at all times and a way to use this memory efficiently when scaled.

Q8. What platforms does docker run on?

Docker runs on various Linux administration:

Ubuntu 12.04, 13.04 et al

Fedora 19/20+

RHEL 6.5+

CentOS 6+

Gentoo

ArchLinux

openSUSE 12.3+

CRUX 3.0+

It can also be used in production with Cloud platforms with the following services:

Amazon EC2

Amazon ECS

Google Compute Engine

Microsoft Azure

Rackspace

Q9. Is there a way to identify the status of a Docker container?

There are six possible states a container can be at any given point – Created, Running, Paused, Restarting, Exited, or Dead.

Use the following command to check for docker state at any given point:

$ docker ps

The above command lists down only running containers by default. To look for all containers, use the following command:

$ docker ps -a

Q10. Can you remove a paused container from Docker?

The answer is no. You cannot remove a paused container. The container has to be in the stopped state before it can be removed.

Q11. Can a container restart by itself?

No, it’s not possible for a container to restart by itself. By default the flag -restart is set to false.

Q12. Is it better to directly remove the container using the rm command or stop the container followed by removing the container?

Its always better to stop the container and then remove it using the remove command.

$ docker stop <coontainer_id>

$ docker rm -f <container_id>

Stopping the container and then removing it will allow sending SIG_HUP signal to recipients. This will ensure that all the containers have enough time to clean up their tasks. This method is considered a good practice, avoiding unwanted errors.

Q13. Will cloud overtake the use of Containerization?

Docker containers are gaining popularity but at the same time, Cloud services are giving a good fight. In my personal opinion, 

Docker will never be replaced by Cloud. Using cloud services with containerization will definitely hype the game. Organizations need to take their requirements and dependencies into consideration into the picture and decide what’s best for them. Most companies have integrated Docker with the cloud. This way they can make the best out of both technologies.

Q14. How many containers can run per host?

There can be as many containers as you wish per host. Docker does not put any restrictions on it. But you need to consider every container needs storage space, CPU, and memory which the hardware needs to support. You also need to consider the application size. Containers are considered to be lightweight but very dependent on the host OS.

Q15. Is it a good practice to run stateful applications on Docker?

The concept behind stateful applications is that they store their data in the local file system. You need to decide to move the application to another machine, retrieving data becomes painful. I honestly would not prefer running stateful applications on Docker.

Q16. Suppose you have an application that has many dependent services. Will docker-compose wait for the current container to be ready to move to the running of the next service?

The answer is yes. Docker composes always runs in the dependency order. These dependencies are specifications like depends_on, links, volumes_from, etc.

Q17. How will you monitor Docker in production?

Docker provides functionalities like docker stats and docker events to monitor docker in production. Docker stats provides CPU and memory usage of the container. Docker events provide information about the activities taking place in the docker daemon.

Q18. Is it a good practice to run Docker compose in production?

Yes, using docker-compose in production is the best practical application of docker-compose. When you define applications with composing, you can use this compose definition in various production stages like CI, staging, testing, etc.

Q19. What changes are expected in your docker-compose file while moving it to production?

These are the following changes you need to make to your compose file before migrating your application to the production environment:

Remove volume bindings, so the code stays inside the container and cannot be changed from outside the container.

Binding to different ports on the host.

Specify a restart policy

Add extra services like log aggregator

Q20. Are you aware of load balancing across containers and hosts? How does it work?

While using docker service with multiple containers across different hosts, you come across the need to load balance the incoming traffic. Load balancing and HAProxy are basically used to balance the incoming traffic across different available(healthy) containers. If one container crashes, another container should automatically start running and the traffic should be re-routed to this new running container. Load balancing and HAProxy work around this concept.

Q21. How does communication happen between the Docker client and Docker Daemon?

You can communicate between the Docker client and Docker Daemon with the combination of Rest API, socket.IO, and TCP.

Q22. Explain the Implementation method of Continuous Integration(CI) and Continues Development (CD) in Docker?

You need to do the following things:

Runs Jenkins on docker

You can run integration tests in Jenkins using docker-compose

Q23. What is the command to control Docker with Systemd?

systemctl start/stop docker

service docker start/stop

Q24. How can you run multiple containers using a single service?

By using docker-compose, you can run multiple containers using a single service. All docker-compose files use yaml language.

Q25. What is CNM?

CNM stands for Container Networking Model. It is a standard or specification from Docker, Inc. that forms the basis of container networking in a Docker environment. This docker approach provides container networking with support for multiple network drivers.


Docker Basic Commands

Exception Handling Interview Questions

DBMS Interview Questions Set -1

DBMS Interview Questions Set -2

SQL Interview Question Set -1

SQL Interview Question Set -2

JPA Interview Questions Set -1

JPA Interview Question Set -2

Hibernate Interview Questions

Spring Boot Interview Questions Set 1

Spring Boot Interview Questions Set 2

GIT Interview Questions

Redis Interview Questions

Core Java Interview Questions Set -1

Docker interview question Set -1

Docker interview question Set -2

Kubernetes Interview Question Set -1

Kubernetes Interview Question Set -2