Image Management
1. In a multi-stage Dockerfile, what is the main benefit of copying only the build output from an earlier stage into the final stage?
The final image excludes build-only tools and intermediate files, keeping it smaller and reducing its attack surface It makes the build run in parallel automatically It is required for Docker to accept the Dockerfile at all It disables layer caching
Check answer Image Management
2. Why is pinning a base image to a specific version tag (e.g. `node:20.11-alpine`) preferred over using `:latest` in production?
`:latest` is not a valid tag `:latest` always points at the smallest image `:latest` can silently change to a different, newer image over time, making builds non-reproducible and introducing untested changes Specific tags disable security scanning
Check answer Networking
3. What is Docker's default bridge network used for?
The default network containers get if none is specified. They can reach the outside world and each other by IP, but not by container name out of the box It's required for Kubernetes integration It only allows one container to run at a time It encrypts all traffic automatically
Check answer Networking
4. What's the practical advantage of a user-defined bridge network over the default bridge network?
User-defined networks let containers resolve each other by container name via built-in DNS, which the default bridge doesn't provide User-defined networks are always faster User-defined networks don't require Docker to be running User-defined networks can only have one container attached
Check answer Orchestration
5. In Docker Swarm, what does setting a service's `replicas` count to 3 actually do?
It runs the container 3 times sequentially, one after another It triples the container's memory allocation It creates 3 separate images It tells the Swarm orchestrator to maintain 3 running instances (tasks) of that service across the cluster, rescheduling if one fails
Check answer Orchestration
6. What does a Docker Swarm 'overlay network' enable that a single-host bridge network can't?
Containers on different physical/virtual hosts in the same Swarm can communicate with each other directly It removes the need for any network configuration It only works for one container at a time It replaces the need for a Swarm manager node
Check answer Security
7. Why does running a container's process as a non-root `USER` in the Dockerfile matter for security?
It makes the image build faster It's required for Docker to pull the image at all Root containers can't connect to any network Running as non-root limits what an attacker can do after exploiting a vulnerability inside the container, both inside it and in common escape scenarios
Check answer Security
8. What risk does running a container with `--privileged` introduce?
It makes the container slightly slower, nothing else It only affects the container's hostname It's required for any container that uses a volume It grants the container almost all the capabilities of the host, largely defeating container isolation — a serious risk if that container is ever compromised
Check answer Image Management
9. What does `docker image prune -a` do?
It deletes every image on the system, used or not It only removes stopped containers It rebuilds all images from their Dockerfiles It removes all unused images (not just dangling ones), freeing disk space
Check answer Image Management
10. Why does Docker layer caching make `COPY package*.json ./` followed by `RUN npm install` appear BEFORE `COPY . .` in a typical Node.js Dockerfile?
It's purely a stylistic convention with no build-time effect Docker requires package.json to be copied first by specification Dependencies only change when package.json changes. Copying it first means that slow install step's layer stays cached on rebuilds where only source code changed It makes the final image smaller
Check answer Storage
11. What's the difference between a named volume and a bind mount in Docker?
A named volume's storage is managed by Docker, its real location abstracted away. A bind mount instead points straight at a real folder on the host They are identical in every way Bind mounts are always faster Named volumes can't persist data across container restarts
Check answer Storage
12. Why might a developer use a bind mount instead of a named volume during local development?
Bind mounts let a container see live edits to source files on the host immediately, without rebuilding the image Bind mounts are required for production deployments Named volumes can't be created without root access Bind mounts automatically back up data to the cloud
Check answer Orchestration
13. In Docker Swarm, what is the role of a 'manager' node versus a 'worker' node?
Manager nodes only run databases; worker nodes run everything else There's no distinction — all nodes are identical in Swarm Manager nodes handle orchestration decisions (scheduling, cluster state) and can run tasks too; worker nodes only execute tasks they're assigned Worker nodes can promote themselves to manager automatically at any time
Check answer Installation & Configuration
14. What does the Docker daemon's `daemon.json` configuration file typically control?
Only container network names Only which user can run `docker` commands Individual container resource limits Daemon-wide settings — e.g. default logging driver, storage driver, registry mirrors, and insecure registries
Check answer Installation & Configuration
15. Why does Docker recommend NOT running the Docker daemon with its default configuration exposed on a plain, unauthenticated TCP socket?
It's purely a performance concern, not security Anyone who can reach that socket effectively has root-equivalent control over the host, since the Docker daemon itself runs as root TCP sockets are deprecated in Docker entirely It would prevent any container from starting
Check answer Networking
16. What does publishing a port with `-p 8080:3000` actually do?
It changes the container's internal port to 8080 It maps host port 8080 to the container's internal port 3000, making the container's service reachable from outside via the host's port 8080 It opens port 8080 on every container on the host It disables the container's internal networking
Check answer Security
17. What is the purpose of Docker Content Trust (`DOCKER_CONTENT_TRUST=1`)?
It scans images for known vulnerabilities It encrypts all container traffic It requires pulled/pushed images to be digitally signed, so a user can verify an image actually came from the expected publisher and wasn't tampered with It limits how much CPU a container can use
Check answer Orchestration
18. What does Swarm's rolling update feature help avoid during a service update?
It avoids the need for a Dockerfile entirely Taking the entire service offline at once — instead, it updates a controlled number of replicas at a time, keeping the rest available It avoids the need for health checks It skips pulling the new image
Check answer Image Management
19. What's the difference between `docker build --no-cache` and a normal `docker build`?
`--no-cache` deletes the final image after building it `--no-cache` forces every instruction to re-run from scratch, ignoring any previously cached layers, instead of reusing unchanged layers `--no-cache` only affects the final layer There's no actual difference in behavior
Check answer Storage
20. What happens to data written to a container's writable layer (not a volume or bind mount) when that container is removed?
It's automatically backed up to Docker Hub It's lost — the container's writable layer is deleted along with the container itself It moves to a named volume automatically It stays on disk indefinitely even after the container is deleted
Check answer