Top 30 Docker Interview Questions and Answers 2021

Docker-Container are very popular open source software platform and now its been adopted by most of the organisations. In this article, We are going to give you most asked and real time interview questions and answers so, that you can clear your interview easily for Docker-Containers.

We have divided this questionnaire in three categories which are basic, intermediate and advanced. So, we will cover only basic questions and answers in this article.

top-30-docker-interview-questions-and-answers-2021

So, let’s start with top 30 docker interview questions and it’s answers for 2021

Q.1. Can you explain what is Docker exactly ?

Ans- Docker is an open sourced tools or containerization platform. It is used to auto deploy of any applications using light weight containers. Containers allow us to wrap up all required dependencies such as libraries and applications all resources into one single package and developer can do the deployments in one go.

Q.2. Why should use Docker and containers?

Ans- Docker-containers provides benefits for us such as:

  • OS level process isolation
  • containers are very light weight and due to that easy to transfer anywhere
  • containers boots in seconds
  • Containers take less resource usage
  • We can create custom docker images and containers.

Along with above benefits docker provides the features such as:

  • Application agility
  • Developer productivity
  • Easy modeling
  • Operational efficiencies
  • Placement and affinity
  • Version control

That’s why we have to use Docker-Containers. Docker containers are mostly suitable for micro services applications.

Q.3. Can you just tell us about Docker Engine?

Ans- When we have installed Docker tool on any machine, that’s machine have Docker service installed. So, docker daemon or docker engine are represents the docker server.

Q.4. Do you know? What is Docker Image?

Ans- A docker image is a file comprised of multiple layers and that is used to execute code in a docker container. Docker image built from the set of instructions and this image used to create and build application ready containers.

Q.5. What is the registries or Docker registries?

Ans- In simple terms registries are nothing but it is a repository. There are two types of repository one is Public and second is Private. Docker having its own registry and its called Docker-Hub.

Q.6. What is containers ?

Ans- You can say containers are standard unit of software that having  packages, code and all its dependencies to run the applications reliably and quickly. In other terms you can say containers are executable package of software that includes everything needed to run an application such as code, runtime, system tools, system libraries and settings

Q.7. Which command used to check all running containers ?

Ans- $ docker ps

Q.8. What command we should use to stop container?

Ans- $ sudo docker stop container name

Q.9. Can you tell us all the states of Docker container?

Ans-  Containers having four important state and that’s are: Created, Restarting, Paused, Exited and Dead.

Q.10. Do you know about Dockerfile ?

Ans- Dockerfile nothing but it is text based file and have set of instructions that we need pass on the Docker so that we can built the image. This set of instructions are a commands which we have to give and that runs one after other when run the docker file.

Q.11. What are the disadvantages of Docker?

Ans- Docker having some limitations or disadvantages we can say and thats are:

  • lack of storage options,
  • monitoring options are less that in ideal machine,
  • you can’t automatically reschedule inactive nodes or containers,
  • auto horizontal scaling setup are complicated.

Q.12. How docker file works? Or whats the the workflow of docker file?

Ans- Docker file is text based file and that file has set of commands, by running docker file we can build or create required image and using that image we can create container. Below image can show you the workflow of docker file.

Q.13. What is docker namespace?

Ans- A namespace is an Linux feature that ensures OS resources partition in a mutually exclusive manner. This forms the core concept behind containerisation as namespaces introduce a layer of isolation amongst the containers. So, in docker, namespaces ensure that the containers are portable and they don’t affect the underlying host. If we give the examples for namespace types that are currently being supported by Docker which are:  PID, Mount, User, Network, IPC

Q.14. Which command you used to list out all containers ?

Ans- To check running containers we can use- $dicker ps  command and to check all running plus stopped containers we can use $ docker ps -a command

Q.15. When data can be deleted from the containers?

Ans- Data would be not deleted from the containers until and unless you delete the containers.

Q.16. Can you tell us something about Docker components?

Ans- Docker has three main components-

  • Docker client- This component performs “build” and “run” operations for the purpose of opening communication with the docker host.
  • Docker host- This component has the main docker daemon and hosts containers and their associated images. The daemon establishes a connection with the docker registry
  • Docker registry- This component stores the docker images. There can be a public registry or a private one. The most famous public registries are Docker Hub and Docker Cloud

Q.17. How you will export docker image as an archive?

Ans- We can use docker save command for this. Sample syntax as mentioned below;

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

Q.18. A container is in paused state, how do we remove or delete it ?

Ans-  Container should be in stopped state, we can’t delete or remove when it is in paused state.

Q.19. How do you check the version of installed docker client and server?

Ans- To check all the informations about docker version we can use below commands:

$docker version
$docker version --format '{{.Server.Version}}'

Q.20. Can you tell us about containers container’s lifecycle?

Ans- To tell about container’s lifecycle, you can give the workflow of the below steps;

  1. Create container
  2. Run container
  3. Pause container
  4. Unpause container
  5. Start container
  6. Stop container
  7. Restart container
  8. Kill container
  9. Destroy container

Q.21. Tell us the difference between stop and kill?

Ans- Stop command will stop the container but first it will gives the time to container to stop all running loads. Whereas Kill command immediately stopped running container.

Q.22. What does docker system prune command ?

Ans- It’s a command used to remove all stopped containers, unused networks, build caches, and dangling images. We can use this command-

$ docker system prune

Q.23. What are dangling images?

Ans- Dangling images are layers that have no relationship to any tagged images. They no longer serve a purpose and consume disk space. An unused image is an image that has not been assigned or used in a container

Q.24. Which command stop the container ?

Ans-

$sudo docker stop [container-name or id]

Q.25. Can you tell us how to create container from the image?

Ans-  We can use below command to create container, if image available on the local machine it will use it or it would be pull from the remote registry.

$ docker run -it -d <image_name>

Q.26. How you can check stored Docker Volume?

Ans- To check the stored docker volume we can use the command;

/var/lib/docker/volumes

Q.27. Can you tell us about docker object labels?

Ans- Labels are nothing but the mechanism for applying metadata to Docker objects such as containers, images, local daemons, networks, volumes, and nodes.

Q.28. Do you know what is the Docker Swarm?

Ans- Docker Swarm is a container orchestration tool native to Docker, that enables applications to run seamlessly across multiple nodes that share the same containers. In essence, you use the Docker Swarm model to efficiently manage, deploy, and scale a cluster of nodes on Docker.

Q.29. Tell us the difference between Docker Image and Layer?

Ans- A Docker image is has a series of read-only layers. Each layer represents an instruction in the image’s Dockerfile. The below Dockerfile contains four commands, each of which creates a layers and most Importantly, each layer are only a set of differences from the layer before it.

FROM ubuntu:15.04 

COPY . /app 

RUN make /app

 CMD python /app/app.py

Q.30. What is the difference between docker image and container?

Ans- Docker container is the runtime instance of docker image. Docker Image doesn’t have a state and its state never changes as it is just a set of files whereas the docker container has its execution state.

 

Hope above mentioned top 30 docker interview questions and answers will help you out to crack your docker-containers interview.

 

Reference:

www.docker.com

www.hub.docker.com

Related Article:

What is Docker Containers Lets understand it with simplest way

How to install docke

DevOps Article

DevOps Article. Your Learnings Hub.

1 thought on “Top 30 Docker Interview Questions and Answers 2021”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.