Top 20 Docker Interview Questions and Answers for DevOps Engineers

Being a DevOps Engineer, you should have deep understanding of docker containerization technology. In every devops engineer technical interview, it is obvious interviewer will ask questions from docker. Here we consolidated frequently asked top 20 docker interview questions and answers for devops engineers.

Que: 1- What is Docker?

Ans: Docker is a Container management technology that packages your application and all its dependencies altogether in the form of Containers to ensure that your application works seamlessly in any environment.

Que: 2- What is Docker image?

Ans: Docker images are the main source of Docker container. In other words, Docker image is used to create containers.

Que: 3- What is Docker Container?

Ans: Docker Container is the running instance of Docker Image.

Que: 4- How to stop and restart the Docker container?

Ans: To stop the container, following syntax would be used.

$ docker stop <container-ID>

To restart the Docker container, following syntax would be used.

$ docker restart <container-ID>

Que:5- How would you get the number of containers running, paused and stopped?

Ans: The following command can be used to get detailed information about the docker installed on your system.

$ docker info

Que: 6- what is docker compose?

Ans: Lets suppose you want to run multiple docker container, at that time you have to create the docker compose file and type the command docker-compose up. This will spin up all the containers mentioned in docker compose file.

Que: 7- syntax for building docker image.

Ans: You can build docker image using following syntax,

$ docker build –f <filename> -t image-name:version

Que: 8- What is the main difference between docker image and docker container?

Ans: Docker image is a read only template that contains the instructions for a container to start. Whereas Docker container is a runnable instance of a docker image

Que: 9- What is Docker Namespace?

Ans: A namespace is a Linux features and an important concept of containers. Namespace usually add a layer of isolation in containers. Docker provides various namespaces in order to stay portable and do not affect the underlying host system. Here are few namespace supported by Docker – PID, Mount, IPC, User, Network etc.

Que: 10- How to log into a container?

Ans: To log into a container, following command can be used.

$ docker exec –it <container-ID> /bin/bash

Que: 11- What is docker swarm?

Ans: Docker Swarm is a collection of either virtual or physical machines or both physical and virtual machines which are running the docker application and that have been configured to join together in a cluster. Once group of machines have been clustered together, you can still run the Docker commands that you’re used to deploy application.

Que:12- What are the common instruction in Dockerfile?

Ans: Here are few common instructions that are used frequently in Dockerfile

  • FROM
  • LABEL
  • RUN
  • CMD

Que:13- What the states of Docker container?

Ans: Important states of Docker container are:

  • Running
  • Paused
  • Restarting
  • Exited

Que:14- Write a Dockerfile to create and copy a directory and built it using python modules?

Ans: You can write a dockerfile to create and copy a directory as follows,

FROM pyhton:2.7-slim
WORKDIR /app
COPY . /app
docker build –tag

Que:15- Where the docker volumes are stored?

Ans: Docker volumes are stored in below location in your docker host.

$ /var/lib/docker/volumes

Que:16- Can you lose data when the container exits?

Ans: No, any data that your application writes to disk get stored in container. The file system for the container will persist even after the container halts.

Que:17- What are a different kind of volume mount types available in Docker?

Ans: Follow below link to get deep understanding of docker volumes.

Read Here : How to configure Docker Volumes

Que:18- What are the three components of Docker Architecture?

Ans: Here are the three main components of Docker Architecture,

  • Client
  • Docker-Host
  • Registry

Que:19- What is Port mapping in docker?

Ans: Follow below link to get deep understanding of docker networking and port mapping.

Read Here : How to configure Networking and Port Mapping in Docker

Que:20- How can you run multiple containers using a single service?

Ans: By using docker-compose, multiple containers can be run using a single service. All docker-compose files uses yaml language.

In this guide, you have gone through top 20 Docker interview questions and answers for devops engineers.. Please comment below for any query or suggestions.

Read Also : Top 25 AWS Cloud Admin Interview Questions and Answers

Read Also : Top 20 DevOps Interview Questions with Answers

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.

Recommended Reading..

Leave a Comment