Skip to content
CompanyBenchCompanyBench

Docker interview questions and answers

Docker interview questions with short answers on images, containers, Dockerfiles, volumes, registries, orchestration and keeping image size down.

Intermediate and advanced Docker questions on containers, images, Dockerfiles, volumes, registries and orchestration, with short answers.

Related: Kubernetes interview questions and contract DevOps engineers.

Questions and answers

What is Docker and why is it used?

Docker is a platform for building, shipping and running applications in isolated environments called containers. The app behaves the same in every environment, which simplifies DevOps work.

What is the difference between a Docker image and a Docker container?

An image is a snapshot or blueprint of an application. A container is a running instance of that image, with its own process and environment.

What is a Dockerfile and what are its key instructions?

A Dockerfile is a script of instructions for building an image. Common instructions are FROM, RUN, COPY, CMD and EXPOSE.

What are Docker volumes and why are they used?

Volumes are persistent storage outside the container's writable layer. Their data survives container removal and can be shared between containers.

How do you orchestrate multiple Docker containers?

With Docker Compose or Kubernetes. Compose defines a multi-container application in one YAML file.

What is the Docker daemon?

The Docker daemon (dockerd) listens for Docker API requests and manages images, containers, networks and volumes.

What is a Docker registry, and what is Docker Hub?

A registry stores Docker images. Docker Hub is Docker's public registry; teams can also run private ones.

What is the difference between docker stop and docker kill?

docker stop sends SIGTERM, which gives the process time to shut down cleanly. docker kill sends SIGKILL, which ends the container immediately.

How do you reduce Docker image size?

Use multi-stage builds and small base images such as alpine, combine RUN commands, and delete unneeded files in the same layer.

What is the difference between docker commit and docker build?

docker commit makes an image from a hand-modified container, which is not reproducible. docker build makes it from a Dockerfile, so the result can be rebuilt reliably.