D
DevPrepSystematic Prep
DOCKER · MEDIUM CODEX

Docker Interview Questions — Medium

Real-world mechanisms, state management, edge cases, performance trade-offs, and practical coding.

50 Theory Questions5 Free Model Answers
THEORY QUESTIONS & SOLUTIONSShowing 5 of 50 questions
Q1Detail the architecture of the Docker Engine.
  • Client-Server Architecture: Composed of three primary parts:
    • Docker Client (docker): The CLI tool that accepts user commands and communicates with the daemon over a REST API (via Unix sockets or TCP).
    • Docker Daemon (dockerd): A background service that listens for API requests and manages Docker objects (images, containers, networks, volumes).
    • Containerd & Runc: The daemon relies on containerd (container lifecycle management) which spawns runc (the lightweight OCI-compliant runtime) to create and run containers.
Q2How does BuildKit differ from the legacy Docker builder?
  • BuildKit: The modern, highly optimized build engine (enabled via DOCKER_BUILDKIT=1).
  • Advantages over legacy:
    • Parallel Execution: Builds independent stages concurrently.
    • Cache Mounts: Supports mounting compilation caches (RUN --mount=type=cache) that persist between builds.
    • Secrets Mounts: Mounts build secrets (RUN --mount=type=secret) securely without baking them into final image layers.
    • Garbage Collection: Intelligent, automatic cleanup of intermediate build states.
Q3Explain how Docker image layers work and how they share space.
  • Union File System (UnionFS): Docker images are stacked layers where each layer represents a instruction in the Dockerfile.
  • Layer Immutability: Each layer is read-only.
  • Storage Sharing: If multiple images share the same parent layer, that layer is stored only once on disk.
  • Writable Layer: At runtime, Docker adds a thin, writable container layer. Read operations fall back to the image layers, while modifications copy the file up to the writable layer (Copy-on-Write).
Q4Explain the HEALTHCHECK directive and its parameters.
  • Purpose: Instructs Docker how to test a container to verify it is actively functioning (not just running as a zombie process).
  • Key Parameters:
    • --interval=30s: Time between checks.
    • --timeout=5s: Maximum time allowed for a single check.
    • --start-period=10s: Initial grace period for slow-starting apps.
    • --retries=3: Number of consecutive failures before marking as unhealthy.
  • Exit Codes: The test script must exit with 0 (healthy) or 1 (unhealthy).
Q5How do Docker networks handle service discovery?
  • Embedded DNS: Docker runs an internal DNS server at 127.0.0.11 inside each container.
  • Service Name Resolution: Within a user-defined network, containers resolve neighboring container IPs by using their container names or network aliases.
  • Limitation: The default bridge network does not support embedded DNS and requires outdated --link flags.

Unlock the remaining 45 Docker (Medium) questions

You've completed the 5 free sample questions. Get unrestricted lifetime access to every question, model answer, implementation challenge, and all 27+ technologies for a single payment.

₹399 India / $9 International · One-time settlement · Zero subscription

CROSS-DIFFICULTY NAVIGATION

Continue Preparing Docker

Docker Interview Questions (Medium) | DevPrep | DevPrep