Docker
99 bites tagged Docker — interview questions with model answers, and 60-second explainers.
Multi-stage Docker builds for lean production images?
Build stage compiles/installs, runtime stage copies artifacts only, discards build tools. Docker build optimization and separation of build and runtime.
What are key Dockerfile steps for Node.js Express apps?
Use lightweight base image, copy app, install deps, expose port, set NODE_ENV, run. Docker containerization fundamentals for Node.js.
Bind mounts vs named volumes for persisting Docker data?
Persist data outside the writable container layer via a bind mount (a host path you control) or a named volume (Docker-managed under its data dir, portable and the recommended default). Docker storage options.
Bind mounts versus named volumes
A bind mount maps a host path into the container (great for live source in dev); a named volume is Docker-managed storage decoupled from the host layout (ideal for database data). Docker storage model.
What is a dangling image and how to prune it
A dangling image is an untagged layer (<none>:<none>) orphaned when a tag moves to a rebuilt image; list with docker images -f dangling=true, remove with docker image prune. image lifecycle and cleanup.
Debug a running container with the Docker CLI
Docker inspect for full state and config, docker logs -f to follow output live, docker exec -it <id> sh or bash for an interactive shell. practical container debugging.
Build, tag, and run a container with port mapping
Docker build -t my-app:1.0 . to build and tag; docker run -d -p 8080:80 my-app:1.0 to run detached with host:container port mapping. core build and run CLI fluency. reversing the port order or forgetting the build context dot.
What is a container vs a VM?
Containers share the host kernel and isolate via namespaces and cgroups; VMs run a full guest OS on a hypervisor; containers are lighter and faster. understanding of OS-level virtualization.
Deploy a saved model as a REST prediction service
Load the artifact, wrap it in a predict API, containerize, host with autoscaling, add monitoring. end-to-end deployment basics. jumping to model training or forgetting preprocessing parity and input validation.
Multi-stage Docker builds
A build stage compiles with the toolchain, the final stage uses a minimal base and copies only the artifact, cutting size and attack surface. separating build tooling from runtime. shipping compilers and source.
Writing a Dockerfile for a web app
FROM a base, set WORKDIR, install dependencies before app code for cache reuse, EXPOSE the port, CMD the start command. core Dockerfile instructions and layering. copying everything before installing deps, or root.
CI/CD pipeline for a container PaaS
Run tests, build the image, push the tag to a registry, then deploy it to Cloud Run. The registry is the build-to-deploy handoff. the build-push-deploy pipeline. skipping the registry or rebuilding on the deploy host.
Docker layers and build cache efficiency
Each instruction makes a content-addressed read-only layer stacked by a union FS; shared layers are pushed/pulled once, and ordering the Dockerfile so volatile steps come last maximizes cache reuse. layer/union FS and caching.
Create a Deployment with 3 replicas via kubectl
Kubectl create deployment webapp --image=my-app:1.0, then kubectl scale to 3 replicas, or use --replicas if supported. Basic kubectl Deployment fluency.
Manifest lists and multi-arch images
A manifest list maps platform descriptors to per-arch image manifests, the client picks by os and architecture, and pulls only that variant. how one tag serves multiple architectures.
Three techniques to shrink a Docker image
Multi-stage builds to drop build tooling, smaller base images like slim or distroless, and fewer or cleaner layers plus dockerignore. practical image-size reduction with trade-offs.
Tag and push an image to a private registry
Authenticate with docker login, retag the image to include the registry host and repo path, then docker push that full reference. tag-and-push workflow plus registry auth.
Docker Compose profiles for optional services
Profiles tag services so they stay off by default, activate via --profile or COMPOSE_PROFILES, and unprofiled services always run. gating optional services in one Compose file.
Optimizing Dockerfile layer caching
Order instructions least-to-most volatile, copy dependency manifests and install before copying source, and understand any changed layer busts all later layers. how layer caching invalidation works.
Structuring Compose files across environments
A base compose.yaml plus override files, the default override auto-merge, and explicit -f flags or extends per environment. Compose override and merge mechanics.
Explain multi-stage Docker builds for Python and builder vs runtime
Tests separation of build-time and runtime concerns. A strong answer contrasts the builder stage (gcc, headers, wheels) with the runtime stage (slim base, copied artifacts, no compiler). Red flag: citing size alone while ignoring security and caching.
How do you manage configuration and secrets for a containerized FastAPI app?
Tests 12-factor config separation and Docker secret hygiene. A strong answer uses pydantic-settings with runtime env vars, lru_cache, and keeps .env out of the image. Red flag: baking credentials into Dockerfile layers or committing .env files.
Walk me through a basic Dockerfile for a FastAPI app
Slim base, install deps before app code to cache layers, expose port, exec-form CMD for Uvicorn. Docker layering and build cache for Python containers. Shell-form CMD or code-before-requirements, killing cache.
Docker Compose for Local FastAPI Stacks
Docker Compose turns your laptop into a one-command datacenter. Define Postgres, Redis, and your FastAPI app in one YAML file and they boot as a networked stack.
Get Docker bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.