docker Interview Questions
Beginner Level5 questions
Platform to package apps + dependencies into portable containers that run anywhere.
Containers share host OS (fast, light); VMs run full OS (heavy, isolated).
Read-only template (OS + code + deps) used to create containers, built in layers.
Recipe file with instructions (FROM, COPY, RUN, CMD) to build Docker images.
build, run, ps, stop, images, logs, exec — the essential Docker commands.
Intermediate Level7 questions
Dockerfile with node:alpine base → copy package.json → npm ci → copy code → CMD.
YAML file defining multi-container apps — run everything with one command.
Persist data outside containers — survives container restart/removal.
Connects containers — bridge (default), custom bridge (by name), host, overlay.
Multiple FROM stages — build in one, copy only output to final small image.
Separate Dockerfiles for React + Node.js, docker-compose.yml ties them together with MongoDB.
Use -e flag, docker-compose environment, or .env files — never hardcode secrets in Dockerfile.
Advanced Level5 questions
Non-root user, specific tags, scan images, no secrets in images, limit resources.
Alpine base, multi-stage builds, combine RUN, .dockerignore, production-only deps.
Build image → test → push to registry → deploy with new tag. Consistent and reproducible.
Managing containers at scale — Kubernetes handles deployment, scaling, healing automatically.
Use docker logs, exec, inspect for debugging; docker system prune for cleanup.