What is the difference between a Docker image and a container?
Assesses fundamental understanding of Docker conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
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.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.