Docker and Container Interview Questions with Answers
Docker interviews test images, processes, storage, networking and the operational behaviour of containers. Explain what each setting changes rather than assume that a container label proves the application works. In the fictional case below, a container remains running while its health check fails. A restart policy does not, by itself, restart an ordinary Docker container merely because it becomes unhealthy.
Topic: Containers: Docker & Podman in IT Infrastructure · Interview preparation
Quick answer: Docker interviews test images, processes, storage, networking and the operational behaviour of containers. Explain what each setting changes rather than assume that a container label proves the application works. In the fictional case below, a container remains running while its health check fails. A restart policy does not, by itself, restart an ordinary Docker container merely because it becomes unhealthy. Distinguishing process exit, health status and dependency readiness leads to a much clearer answer than recommending repeated restarts.
Key takeaways
- An image and a running container have different lifecycles.
- Container health status is separate from the main process state.
- Restart policies respond to their documented conditions, not every application symptom.
- Persistent storage still needs access control and recovery planning.
- Build secrets, image provenance and runtime permissions need deliberate handling.
Table of Contents
- How do you explain containers, images and Docker components?
- Which Dockerfile and image answers need precision?
- How do volume and lifecycle answers differ?
- Which networking and Compose questions commonly follow?
- How should you answer build and runtime security questions?
- Why did an unhealthy container not restart?
- Which follow-up answers demonstrate operational judgement?
- References
How do you explain containers, images and Docker components?
1. What is a container? An isolated process environment with its required user-space files and configuration. The Docker container and virtual-machine introduction compares containers with virtual machines; containers do not each supply an independent kernel.
2. Container versus VM? A VM supplies a guest operating system and kernel. Containers share the kernel of their execution environment, which may itself be a VM on a desktop or cloud platform.
3. Image versus container? An image is a packaged filesystem and configuration template; a container is an instantiated environment with runtime state and a writable layer.
4. Client, daemon and registry? The client requests operations, the engine manages container resources, and a registry stores distributed images. The active context can point at a different engine than expected.
5. Does portability mean identical behaviour everywhere? Architecture, kernel interfaces, configuration, external services and resource constraints still affect compatibility and operation.
Which Dockerfile and image answers need precision?
6. What are image layers? Immutable filesystem changes assembled into an image. The Docker image-layer guide explains reuse and the separate writable layer for a container.
7. Dockerfile versus image? The file describes build instructions; the resulting image depends on inputs, base image, dependencies and build behaviour.
8. RUN versus CMD versus ENTRYPOINT? RUN performs build-time work. CMD supplies default runtime command or arguments, while ENTRYPOINT defines the executable arrangement; shell and exec forms behave differently.
9. COPY versus ADD? COPY handles ordinary source copying; ADD has additional capabilities. Choose intentionally instead of assuming additional behaviour is always desirable.
10. Tag versus digest? Tags can be reassigned; a digest identifies image content. A digest does not independently establish trusted authorship or an acceptable vulnerability posture.
11. What is a multi-stage build? It separates stages so selected artifacts can enter the final image without carrying every build dependency. It does not automatically remove secrets copied into retained artifacts.
How do volume and lifecycle answers differ?
12. Writable layer versus volume? Container-layer changes belong to that container’s lifecycle; volumes provide separately managed storage. The Docker volume guide explains volume persistence beyond an individual container.
13. Volume versus bind mount? Docker manages volume storage; bind mounts refer to host paths and expose their associated dependencies and access concerns.
14. Does persistent mean backed up? No. Protect required data, define recovery points and test restoration; a persistent volume can retain corruption or unwanted changes.
15. Stop versus remove? Stopping ends execution according to the configured process and signal handling; removing discards the container object and applicable writable state. Storage removal has its own rules.
16. Why care about the main process? Container lifetime follows its main process. Application child-process handling, signals and graceful shutdown require a suitable entrypoint arrangement.
| Item | What it establishes | What remains separate |
|---|---|---|
| Image digest | Content identity | Trusted origin and acceptable risk |
| Running container | Main process has not exited | Application health and useful response |
| Persistent volume | Storage lifetime separate from container | Protected recovery and data correctness |
| Health check | Result of the configured probe | Every business function is correct |
Which networking and Compose questions commonly follow?
17. EXPOSE versus publishing a port? EXPOSE documents intended ports in image metadata. Publishing configures host access through the applicable network arrangement; it does not override every firewall or application bind setting.
18. Default bridge versus user-defined network? Name resolution and isolation behaviour differ. The Docker networking guide explains network membership, drivers and published ports; use the actual network design in an answer.
19. What does Compose do? It describes and manages a multi-container application’s services and dependencies. It is not identical to a cluster scheduler or an unlimited availability service.
20. Does depends_on mean ready? Basic dependency ordering does not wait for useful application readiness. The Docker Compose startup-order guide documents service_healthy and successful-completion conditions.
21. Does startup readiness handle every later outage? No. Applications still need appropriate connection handling and recovery when dependencies fail after startup.
How should you answer build and runtime security questions?
22. Are containers a complete security boundary? Isolation depends on kernel, runtime and configuration. Privileged operation, host mounts and engine access can greatly expand consequences.
23. Why avoid secrets in build arguments? They can persist in image-related artifacts. The Docker build-secret guide describes secret mounts and SSH mounts; the build must also avoid copying or printing secret values.
24. Does a non-root user solve every permission problem? It reduces selected privileges, but mounted files, capabilities and application needs still require review.
25. Why limit resources? Unbounded workloads can contend with neighbours or exhaust host resources. Limits need a measured application requirement, not an arbitrary number.
26. Image scan versus runtime observation? They cover different evidence. Inventory findings need applicability and remediation review, while runtime monitoring can reveal behaviour absent from an image-only assessment.
Why did an unhealthy container not restart?
In a fictional support record, the main process is still running, health status is unhealthy, and restart policy is on-failure. The supplied probe repeatedly fails because a required local application endpoint does not meet its expected response. There is no process exit in the record.
The Dockerfile reference defines health status in addition to normal container status. The Docker restart-policy guide ties ordinary restart policies to exits and documented daemon/start conditions. An unhealthy label alone does not satisfy an on-failure exit condition.
Explain that distinction before changing the policy. Review probe purpose, failure output, timing and actual application dependencies with the owner. A failing probe can reflect a real problem or a badly chosen check; the supplied record alone does not decide which.
| Invented evidence | Supported answer |
|---|---|
| Main process is running | No process exit is established |
| Health status is unhealthy | Configured probe has reached its failure condition |
| Policy is on-failure | An exit with failure is required for that ordinary restart trigger |
| Probe endpoint fails | Review the endpoint requirement and application evidence |
Which follow-up answers demonstrate operational judgement?
27. Does restart always cure the problem? It can interrupt work and repeat the same failure. Establish the cause and the owner’s approved recovery action first.
28. Does a healthy check prove the whole application works? It establishes only the probe’s tested condition at that time. An order-processing or data-integrity requirement may need separate acceptance evidence.
29. How would you inspect an unfamiliar deployment? Identify engine context, image identity, process state, health configuration, mounts, networks, logs and application ownership before proposing a change.
30. How should the fictional ticket close? Record whether the probe or application was corrected through the approved workflow, then retain a fresh probe result and the relevant application check. Merely changing the policy label or suppressing the warning does not demonstrate restored behaviour.
Related reading: Docker image and runtime concepts; Kubernetes workload interview reasoning.
References
Frequently Asked Questions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Wow
0
Sad
0
Angry
0