Tech

Docker

Docker revolutionized software delivery by popularizing containerization — packaging an application and all its dependencies into a portable, isolated unit. It eliminates the "works on my machine" problem and is now a core part of modern CI/CD pipelines. Interviews cover Dockerfile authoring, image layering, container networking, volume management, and how Docker integrates with orchestration tools like Kubernetes.

What you get

Questions

20

Difficulty

3 levels

Answer Formats

2

Use the toggle on each card to move between an interview-ready answer and a simpler explanation. Questions are sorted from beginner to advanced, and the keywords are highlighted. You can also blur the answers to practice recalling them from memory.

Questions

Practice the answers out loud.

All topics

Question 1

What is Docker?

Beginner

How to answer in an interview

Docker is a platform for developing, packaging, and running applications in lightweight, portable containers that bundle an application with all its dependencies. Containers share the host OS kernel but run in isolated user spaces, making them more resource-efficient than traditional virtual machines while ensuring consistent behavior across environments.

Question 2

What is the difference between a container and a virtual machine?

Beginner

How to answer in an interview

A virtual machine runs a full guest operating system on top of a hypervisor, making it heavier and slower to start. A container shares the host machine's OS kernel and only packages the application and its dependencies, making it much lighter, faster to start, and more resource-efficient than a VM.

Question 3

What is a Docker image?

Beginner

How to answer in an interview

A Docker image is a read-only, immutable template containing an application's code, runtime, libraries, and dependencies, built from a set of instructions in a Dockerfile. Running an image creates a container, which is a live, running instance of that image.

Question 4

What is a Dockerfile?

Beginner

How to answer in an interview

A Dockerfile is a text file containing a series of instructions, such as FROM, RUN, COPY, and CMD, that Docker uses to automatically build a Docker image in a repeatable, versionable way.

Question 5

What is the difference between COPY and ADD in a Dockerfile?

Beginner

How to answer in an interview

COPY simply copies files or directories from the build context into the image. ADD does everything COPY does but also supports extracting local tar archives automatically and fetching files from remote URLs. Because ADD's extra behaviors can be surprising, COPY is generally recommended unless ADD's specific features are needed.

Question 6

Explain the Docker container lifecycle.

Beginner

How to answer in an interview

A Docker container's lifecycle includes states like created, when it's set up but not started; running, when the process inside is actively executing; paused, when execution is temporarily suspended; stopped, when the process has exited; and removed, when the container is deleted entirely along with its writable layer, unless data was stored in a volume.

Question 7

What is Docker Hub?

Beginner

How to answer in an interview

Docker Hub is a cloud-based registry service for finding, storing, and sharing Docker images, hosting both official images maintained by software vendors and public or private images uploaded by the community. Developers can pull existing images or push their own built images for others to use.

Question 8

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

Beginner

How to answer in an interview

A Docker image is a static, read-only template containing everything needed to run an application. A container is a live, running instance of that image, with its own writable layer on top, allowing changes to be made while it's running without affecting the original image.

Question 9

Explain Docker layers and image caching.

Intermediate

How to answer in an interview

Each instruction in a Dockerfile creates a new read-only layer stacked on top of previous ones using a union filesystem, and Docker caches these layers so unchanged instructions don't need to be rebuilt. This makes builds faster if you order instructions carefully, placing frequently changing steps like copying application code near the end of the Dockerfile.

Question 10

What is Docker Compose?

Intermediate

How to answer in an interview

Docker Compose is a tool for defining and running multi-container Docker applications using a single YAML file, docker-compose.yml, where you specify services, networks, and volumes. Running 'docker-compose up' starts all defined services together, simplifying local development and testing of applications with multiple interconnected containers.

Question 11

Explain the difference between CMD and ENTRYPOINT in a Dockerfile.

Intermediate

How to answer in an interview

CMD specifies default arguments or a command for a container, which can be easily overridden when running the container. ENTRYPOINT specifies the main command that always runs, treating any CMD or command-line arguments as parameters to it rather than replacing it entirely, making it better suited for containers meant to behave like a fixed executable.

Question 12

What is a Docker volume?

Intermediate

How to answer in an interview

A Docker volume is a persistent storage mechanism managed by Docker that exists outside a container's writable layer, allowing data to survive container restarts or deletion. Volumes are the preferred way to persist data, such as database files, and can be shared between multiple containers.

Question 13

Explain Docker networking basics: bridge, host, and none.

Intermediate

How to answer in an interview

The default bridge network provides an isolated private network where containers can communicate with each other via internal IPs. The host network removes network isolation, letting a container share the host's network stack directly for maximum performance at the cost of isolation. The none network disables networking entirely for a container.

Question 14

How do you reduce Docker image size?

Intermediate

How to answer in an interview

You can reduce image size by using minimal base images like Alpine Linux, combining related RUN commands to reduce layer count, cleaning up unnecessary files like package caches within the same layer they're created, and using multi-stage builds to exclude build-time dependencies from the final image.

Question 15

How do you persist data in Docker containers?

Intermediate

How to answer in an interview

Data can be persisted using Docker volumes, which are managed by Docker and stored outside the container's filesystem, or bind mounts, which map a specific host directory into the container. Volumes are generally preferred since they're portable and managed independently of the host's file structure.

Question 16

What is docker-compose used for and how does it differ from plain Docker commands?

Intermediate

How to answer in an interview

docker-compose lets you define an entire multi-container application declaratively in a YAML file, specifying services, networks, environment variables, and dependencies between containers, then start or stop the whole stack with a single command, instead of manually running individual 'docker run' commands with many flags for each container.

Question 17

How do you debug a running Docker container?

Intermediate

How to answer in an interview

You can debug a running container using 'docker logs' to view its console output, 'docker exec -it <container> /bin/bash' to open an interactive shell inside the running container, and 'docker inspect' to view detailed configuration and state information about the container.

Question 18

What is container orchestration and why is it needed?

Intermediate

How to answer in an interview

Container orchestration automates the deployment, scaling, networking, and management of containers across a cluster of machines, handling tasks like scheduling containers onto available nodes, restarting failed containers, and load balancing traffic between replicas. It's needed because manually managing large numbers of containers across many servers becomes impractical at scale, which is why tools like Kubernetes were created.

Question 19

What is a multi-stage build in Docker?

Advanced

How to answer in an interview

A multi-stage build uses multiple FROM statements in a single Dockerfile, where each stage can perform different tasks, such as compiling code in a build stage with all necessary build tools, and then copying only the compiled output into a minimal final stage. This keeps the final production image small and free of unnecessary build dependencies.

Question 20

Explain the underlying Linux technologies Docker relies on: namespaces and cgroups.

Advanced

How to answer in an interview

Linux namespaces provide isolation by giving each container its own view of resources like process IDs, network interfaces, and mount points, so containers can't see or interfere with each other. Control groups (cgroups) limit and monitor the amount of CPU, memory, and other resources a container can use, preventing one container from starving others of resources.

More in Tech

Keep browsing related topics.

Browse all