Top 25 Docker Advanced Interview Questions in 2021

Top 25 Docker Advanced Interview Questions in 2021

Docker Interview Questions with Answers (Intermediate/Advanced)

  1. What is Hypervisor?

It is software that helps in making virtualization possible. Its other name is Virtual Machine Monitor. Its main task is to divide the host system. It also does the allocation of resources to the individually divided virtual environment. The two types of Hypervisors are:

    • Bare Metal Hypervisor or Native Hypervisor: This type of hypervisor runs directly on your underlying host system. As it has access to your host hardware, it does not need any base server operating system.
    • Hosted Hypervisor: This hypervisor uses an underlying host operating system and thus the name, hosted hypervisor.
Types of Hypervisors

Image Credit: https://www.dnsstuff.com/what-is-hypervisor

  1. What is Virtualization?

Virtualization can be defined as a process by which we create a virtual, software-based version of anything such as servers, computer storage, applications, etc. It can be done with just a physical single hardware system. A software named Hypervisor comes in use to split a single system into various different sections. These split sections, in turn, work like a distinct, separate individual system.

  1. What is  Docker?

Docker is an open-source lightweight containerization technology. It is a containerization platform that consists of your application along with all of its dependencies in the container form. It makes sure that the application works well and seamlessly in any given environment such as test, production, or development. Docker container is a software piece in a filesystem. It contains everything required to run coding, runtime, system libraries, system tools, etc.

  1. Explain Docker Architecture.

Docker Architecture has a Docker engine which is basically a client-server application. It has 3 major components which are:

    • A server or a kind of long-running program, known as a daemon process. (The Docker Command)
    • A REST API usually specifies the interfaces that can be used by the programs to talk with daemons and to instruct what to do.
    • A CLI (Command Line Interface) client. It uses REST API to interact with or control the Daemon. It is done through CLI commands or scripting.
Docker Architecture and Components

Image Credit : https://www.oreilly.com/library/view/learn-openshift/9781788992329/33d025bf-27fa-49b9-99b3-673a20ae6d1e.xhtml

 

You can also refer to our posts on `A Docker Container Tutorial for Beginners` and `Docker Cheatsheet for Beginners`

DevOps 2021 : A Docker Container Tutorial for Beginners

Docker Cheatsheet for Beginners

  1. How can you check the Docker Client and also the Docker Server version?

You can perform this task by using the `version` command:

$ docker version 

  1. How can you know of the number of containers paused, running, or stopped?

Use the following command to get detailed information of the docker installed:

$ docker info

Using this command, you can know about the number of containers running or paused or a number of images, containers stopped, and much more.

  1. How can you create a Docker container using an image?

Pull out any image from the docker repository and create a container. Use the given command:

 $ docker run -it -d <image_name> 

  1. What is the command used to run all the containers?

Using the following command will list all containers running:

$ docker ps 

  1. How can you stop, start or kill a container? 

To stop a cactusmeraviglietina.it container, use the following command:

$ docker stop <container_id> 

To start a docker container, use the following command:

$ docker start <container_id> 

Kill a container by using the given command:

$ docker kill <container_id> 

  1. How do you build a Docker file?

After writing a docker file, you will now need to build it so as to create the image with the specifications given. Use the given command to build a docker file:

$ docker build <path to docker file> 

  1. When a docker container exits, will your data discard?

No, exiting a docker container will not discard your data. All the data written to the container gets automatically preserved on disk. It will get deleted only when you intentionally delete the container.

  1. Where can you use Docker?

Talking about the various applications of docker, we can conclude that it can be used in the following areas:

    • Code Pipeline Management
    • Simplifying Configuration
    • Developer Productivity
    • Debugging Capabilities
    • Application Isolation
    • Rapid Deployment
    • Multi-tenancy 
  1. Can we use JSON in place of YAML for composing files in Docker?

Yes. YAML is a superset of json so any JSON file should be valid Yaml. To use a JSON file with Compose, specify the filename to use, for example:

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

  1. Are you able to remove a paused container in Docker?

No, you cannot remove any paused docker container. You can only remove a container when it is in the stopped state.

  1. On what platforms can docker run?

Docker is supported and can run on several platforms such as:

    • Fedora 19/20+
    • Ubuntu 12.04, 13.04 et al
    • Gentoo
    • RHEL 6.5+
    • ArchLinux
    • CentOS 6+
    • CRUX 3.0+
    • openSUSE 12.3+
    • Windows

Docker can be used also in production through Cloud platforms with the given services:

    • Amazon ECS
    • Amazon EC2
    • Microsoft Azure
    • Google Compute Engine
    • Rackspace
  1. Can a container get automatically restart?

By default, the flag restart remains false. So, it is not possible for a container to automatically restart.

  1. Is it good if you run stateful applications over Docker?

The concept of statement applications says that their data gets stored on the local file system. So, when you move the application to another device, it will become difficult for you to retrieve data. So, we do not recommend running stateful applications here.

  1. Is it okay to run Compose in production?

Yes, as per our experience, using docker-compose in production is among its top applications. In the process of defining applications with compose, you can use it in various stages of production such as CI, testing, staging, etc.

  19. What is Docker image?

The Docker image help to create Docker containers. You can create the Docker image with the build command. Due to this, it creates a container that starts when it begins to run. Every docker images are stored in the Docker registry.

  20What is a Dockerfile?

Docker builds images automatically by reading the instructions from a Dockerfile — a text file that contains all commands, in order, needed to build a given image.A Docker image consists of read-only layers each of which represents a Dockerfile instruction. The layers are stacked and each one is a delta of the changes from the previous layer.

 Example of a Dockerfile:

FROM ubuntu:18.04
COPY . /app
RUN make /app
CMD python /app/app.py

Each instruction creates one layer:

    • FROM creates a layer from the ubuntu:18.04 Docker image.
    • COPY adds files from your Docker client’s current directory.
    • RUN builds your application with make.
    • CMD specifies what command to run within the container.

21What is a Docker Namespace?

A namespace is one of the Linux features and an important concept of containers. Namespace adds a layer of isolation in containers. Docker provides various namespaces in order to stay portable and not affect the underlying host system. Few namespace types supported by Docker – PID, Mount, IPC, User, Network

  22. What are the lifecycle stages of a Docker Container?

This is again a very common and popular interview question. Docker containers go through the following lifecycle stages:

    • 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

  23. Is it possible to run multiple process inside a single Docker container?

Yes, you can run multiple processes inside Docker container however this approach is discouraged for most use cases.It is generally recommended that you separate areas of concern by using one service per container. For maximum efficiency and isolation, each container should address one specific area of concern. However, if you need to run multiple services within a single container, you can try using tools like Supervisor.

Supervisor is a moderately heavy-weight approach that requires you to package supervisord and its configuration in your image (or base your image on one that includes supervisord), along with the different applications it manages. Then you start supervisord, which manages your processes for you.

   24. Does Docker supports IPv6?

Yes, Docker does supports IPv6.  However IPv6 networking is only supported on Docker daemons running on Linux hosts.Support for IPv6 address has been there since Docker Engine 1.5 release.

To enable IPv6 support in the Docker daemon, you need to edit/etc/docker/daemon.json and set the ipv6 key to true.

{
  "ipv6": true
}

Ensure that you reload the Docker configuration file.

$ systemctl reload docker

You can now create networks with the –ipv6 flag and assign containers IPv6 addresses using the –ip6 flag.

 25. What is a .dockerignore file?

Similar to a .gitignore file, we also have a Dockerignore files which allows you to mention a list of files and/or directories which you might want to ignore while building the image. This would definitely reduce the size of the image and also help to speed up the docker build process.

Before the docker CLI sends the context to the docker daemon, it looks for a file named .dockerignore in the root directory of the context. If this file exists, the CLI modifies the context to exclude files and directories that match patterns in it. This helps to avoid unnecessarily sending large or sensitive files and directories to the daemon and potentially adding them to images using ADD or COPY.

Read Also

What is the UPSC exam

CATEGORIES
TAGS
Share This

COMMENTS

Wordpress (0)
Disqus (0 )
gujarat xnxx orangeporn.info youtubesexvidoes shradha kapoor hot indiansexbar.mobi choti behan ko mom2fuck hindipornblog.com malayalam sexy videos bad masti indian doodhwali.net xnxx school sex hentai rei ayanami adulthentai.net hentai shion
indian pornographic actress oopsmovs.info tamilgirlsnude bangali sexi girl 3porn.info xxx17 backpag bangalore youjizz.sex hindi sex vedio indian ooo sex xxxindianporn.org south indian actress pussy sex video of nepal pornozavr.net 16honey.com
telangana village sex ipornmovs.mobi naked girls sex indian super sex noticieroporno.com heavy r .com sex video lokal cumporn.info telugu andhra sex videos kamasutra porn movie tubepatrol.cc eenadu karnataka xxlxcom borwap.pro rachana narayanankutty