Docker Interview Questions

 Subscribe YouTube Channel @devops-pathshala 



1. What is Docker ?

Ans:- Docker is a platform that allows you to package an application and all its dependencies into lightweight portable containers.

2. What are Containers ?

Ans:- Containers are lightweight, isolated environment that package an application along with all dependencies so it run consistently on any system.

3. What is the difference between a container and a Virtual Machine ?

Ans:- Containers are lightweight because they share the host operating system, while virtual machine are heavy because they run their own full operating system.

Containers start very quickly, use fewer resources and are ideal for microservices. Virtual machines provide stronger isolation but require more RAM and CPU since each VM containers a full OS.

So overall, containers are fast and efficient, whereas VMs are heavier but more isolated.

4. What are docker engine ?

Ans:- Docker Engine is the core component of  Docker that runs and manage containers.

It works as a client-server application where the docker daemon creates, runs and monitors containers and the docker CLI is used to interact with it. It basically provides the runtime environment needed to build, run and manage containers on a system.

5. What are the main components of  docker ?

Ans:- The main components of Docker are:-

1. Docker Engine:- The core service that runs and manage containers.

2. Docker Daemon:- The background process that builds, run and monitors containers.

3. Docker CLI:- Command line tool used to interact with docker.

4. Docker Image:- Read-only templates used to create containers.

5. Docker Containers:- Running instance of  docker image.

6. Docker Registry:- A repository where docker images are stored and pulled from.

6. What is a Docker Image ?

Ans:- A docker image is a read only blueprint used to create containers. It contains the application code, dependencies and environment required to run the application.

7. What is a Dockerfile ?

Ans:- A Dockerfile is a test file that contains a set of  instruction used to build a docker image.

It defines everything your image should have - like base image, software packages, environment variables, copying files and command to run.

8. What are docker volume? why are they used ?

Ans:- Docker volumes are special directories managed by docker that store persistent data outside the containers writable layer.

They allow data to persistent even if the container is deleted.

Why are they used:-

1. To persist data beyond the container lifecycle.

2. To share data between multiple containers.

3. To improve performance compared to bind mounts.

4. To backup and migrate container data easily.


9. Difference between COPY and ADD in Dockerfile ?

Ans:- COPY and ADD both copy files from the host to the container. The differnece is, COPY is simple and only copies local files or directories, while ADD can also download files from a URL and automatically extract .tar archives.

10. What is the purpose of .dockerignore file ?

Ans:- The .dockerignore file is used to exclude files and directories from being copied into a docker image during docker build.

11. What is the difference between CMD and ENTRYPOINT in Dockerfile?

 Ans:- ENTRYPOINT  sets the main command, CMD sets default arguments. CMD is easily overridden at runtime, ENTRYPOINT is not, use ENTRYPOINT  for fixed commands and CMD for default.

12. What is a Docker Registry vs Repository ?

Ans:- A docker registry is like a library that stores many repositories. A docker Repository is like a bookshelf inside the library, containing multiple versions of a specific image.

13. What is Docker Compose ?

Ans:- Docker compose is a tool to run multi- container applications. We define all services, networks and volumes in a docker-compose.yml file and start everything with one command. It makes managing multiple container easy.

14. How to define multiple containers in docker compose >

Ans:- In docker compose, multiple containers are defined under the :services" section of docker-compose.yml. Each service represent a container with its own image, ports and environment. Compose automatically creates and connects all containers.

15. What is Port Binding in docker ?

Ans:- Port binding in docker is mapping a containers internal port to a host port so that application inside the container can be accessed externally.

16. How do you use docker in CI/CD pipelines ?

Ans:- In CI/CD pipelines, docker is used to build, test and deploy applications in containers. The pipeline build a docker image, runs tests inside containers, pushes the image to a registry and deploys it in production. This ensure consistency, solation and faster deployments. 



Comments

Popular posts from this blog

User Management in Linux – Complete Notes for Beginners

DevOps Roadmap 2026 – Your Complete Beginner-to-Expert Guide

What is Public Subnet in AWS? Step-by-Step Explanation with Example