Docker Interview Questions and Answers
Images, layers, volumes, networking and multi-stage builds.
Whether you are preparing for entry-level Docker interview questions for freshers or senior software engineer interview questions addressing concurrency, scalability, and system architecture, this track provides peer-reviewed model answers with syntax walkthroughs, edge cases, and practical interview tips.
1 What is the difference between a Docker image and a container? Easy
An image is a read-only template; a container is a running instance of that image.
- Image: built from a Dockerfile, composed of immutable layers, and stored in a registry. It contains the filesystem and metadata such as entrypoint, environment, and exposed ports.
- Container: an image plus a writable layer and runtime state, including processes, network, and mounts. You can run many containers from one image.
docker build -t web:1.0 .
docker run -d -p 8080:80 --name web web:1.0
docker ps
Think of the image as a class and the container as an object. Changes made inside a container's writable layer are lost when it is removed unless you use a volume. Rebuild and version images rather than editing running containers, and keep images small for faster pulls.
2 What is the difference between CMD and ENTRYPOINT? Easy
Both define what runs when a container starts, but they behave differently.
- ENTRYPOINT sets the executable. It is hard to override and defines the container's purpose.
- CMD provides default arguments to ENTRYPOINT, or a default command if no ENTRYPOINT exists. It is easily overridden by arguments passed to docker run.
ENTRYPOINT ["python", "app.py"]
CMD ["--port", "8080"]
Running docker run image --port 9000 replaces the CMD arguments but keeps the ENTRYPOINT. Use the exec form, the JSON array, so signals such as SIGTERM reach your process directly, which matters for graceful shutdown. Avoid the shell form because it wraps the command in /bin/sh -c and can swallow signals. Combine both for a sensible default that users can still customise.
Frequently Asked Questions About Docker Interviews
What do hiring managers evaluate in Docker technical rounds?
Technical interviewers look for foundational fluency, idiomatic syntax, clarity when communicating complex logic, and awareness of performance trade-offs (e.g. memory footprint, render performance, and network latency) in production environments.
What are the best interview tips for practicing Docker questions?
Use active recall: summarize each answer in your own words before revealing the model solution. Focus on explaining why a certain approach is chosen rather than just memorizing code syntax.