Learn Docker core architecture, production scenario-based questions, incident response, and real-world engineering solutions.
❓ Q1: How would you explain the difference between a container and a virtual machine to someone new to DevOps?
Click on the dropdown below to reveal the technical answer.
Answer:
❓ Q2: What is Docker, and what specific advantages does it bring to the software development lifecycle?
Click on the dropdown below to reveal the technical answer.
Answer: Docker is an open-source platform that enables developers to build, package, ship, and run applications inside lightweight, portable containers. It is widely used in DevOps because it:
❓ Q3: Can you walk me through the low-level container runtime stack (runc, containerd, CRI-O)? What actually happens under the hood when 'docker run' executes?
Click on the dropdown below to reveal the technical answer.
Answer: Docker does not run containers directly; it delegates execution to specialized runtimes:
docker run:dockerd.dockerd calls containerd via gRPC.containerd downloads the image (if missing) and creates the runtime bundle metadata.containerd calls containerd-shim (which keeps the container alive without keeping containerd active).containerd-shim calls runc to create namespaces, attach cgroups, and start the container process.runc exits.❓ Q4: How does Docker use Linux namespaces to isolate container processes?
Click on the dropdown below to reveal the technical answer.
Answer: Namespaces are a Linux kernel feature that provides isolation for container processes, making it appear as if the container has its own dedicated operating system instance.
pid: Isolate process IDs. Processes inside the container cannot see host or other container processes.net: Isolate network interfaces, IP routing tables, and firewall rules.mnt: Isolate filesystem mount points.ipc: Isolate system resources like shared memory.uts: Isolate hostname and domain names.user: Isolate user and group IDs (allows mapping root inside the container to a non-root user on the host).❓ Q5: What are Linux control groups (cgroups), and how does Docker leverage them for resource limits?
Click on the dropdown below to reveal the technical answer.
Answer: Control Groups (cgroups) are a Linux kernel feature that enforces resource limits and metering on processes. Docker uses cgroups to guarantee that containers do not monopolize host resources. It controls limits for:
--cpus=2).-m 512m to prevent out-of-memory issues on the host).❓ Q6: How do containers solve the 'it works on my machine' problem and guarantee consistency in production?
Click on the dropdown below to reveal the technical answer.
Answer:
v1.2.3), allowing teams to easily track, deploy, or revert back to previous releases.❓ Q7: How does Docker construct image layers, and how does the OverlayFS union file system work under the hood?
Click on the dropdown below to reveal the technical answer.
Answer:
Docker images are constructed as a stack of read-only layers. Each instruction in a Dockerfile (e.g., RUN, COPY, ADD) creates a new layer.
Lowerdir: The read-only image layers.Upperdir: The writable container layer containing modifications.Merged: The combined view presented to the running container process.❓ Q8: What are Docker multi-stage builds, and why are they recommended for production container security and size optimization?
Click on the dropdown below to reveal the technical answer.
Answer:
Multi-stage builds use multiple FROM instructions in a single Dockerfile to divide the build process into temporary stages, separating compilation environments from the final production runtime.
# Stage 1: Build & Compile
FROM golang:1.20 AS builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o myapp
# Stage 2: Final Runtime
FROM alpine:3.18
WORKDIR /root/
COPY --from=builder /app/myapp .
CMD ["./myapp"]
❓ Q9: When and why should we use Docker Compose instead of launching containers individually?
Click on the dropdown below to reveal the technical answer.
Answer:
Docker Compose is a tool designed to define, configure, and manage multi-container applications running on a single host. It uses a single YAML file (docker-compose.yml) to define the services, networks, volumes, and ports required for the entire application stack.
depends_on keyword to define startup order (e.g., ensuring a database container starts before the API backend).http://db:5432).docker compose up).❓ Q10: If I give you a legacy VM-based application, what step-by-step approach would you take to containerize it?
Click on the dropdown below to reveal the technical answer.
Answer:
latest./healthz).docker-compose.yml for local testing. Write Kubernetes manifests (Deployments, Services, PVCs, Ingresses) for production.❓ Q11: How do Linux capabilities, seccomp profiles, AppArmor/SELinux, and Trivy fit into securing containers in production?
Click on the dropdown below to reveal the technical answer.
Answer:
CAP_NET_ADMIN, CAP_SYS_ADMIN). Docker strips all non-essential capabilities from container roots by default. You can drop all capabilities and add only what is needed: --cap-drop=ALL --cap-add=NET_BIND_SERVICE.reboot or ptrace).trivy image <image-name>) to detect OS package and dependency vulnerabilities (CVEs) before pushing to production registries.❓ Q12: What are your go-to Docker best practices when designing container images for a production environment?
Click on the dropdown below to reveal the technical answer.
Answer:
0 (root). Declare a non-privileged user (USER appuser) to mitigate container breakout vulnerabilities.RUN statements using && and clean up package managers caches (rm -rf /var/lib/apt/lists/*) in the same layer.latest. Pin base images to specific tags (e.g., node:18-alpine) to ensure predictable build outcomes..dockerignore: Exclude local build directories (node_modules), test suites, and git folders from being copied into the container context.❓ Q13: What is a container escape, and how can we configure containers to prevent them?
Click on the dropdown below to reveal the technical answer.
Answer:
A container escape is a security vulnerability or exploit where a process inside a container bypasses namespace, cgroup, or storage isolation to execute commands directly on the host operating system. This is often caused by running containers with the --privileged flag or mounting the host's /var/run/docker.sock file.