Docker & Containerization Vocabulary
5 exercises — CMD vs ENTRYPOINT, multi-stage builds, layer caching, named volumes vs bind mounts, and image tags vs digests.
0 / 5 completed
Docker vocabulary quick reference
- CMD = overridable defaults; ENTRYPOINT = fixed executable; always use exec form (JSON array)
- multi-stage build — multiple FROM; final stage copies only what's needed; drastically smaller images
- layer cache — invalidated if inputs change; put slow instructions (install deps) before frequently-changing ones (COPY source)
- named volume = Docker-managed persistent storage; bind mount = host path;
down -vdeletes named volumes - latest tag = mutable, non-deterministic; pin to specific version or digest (sha256: hash) for reproducibility
1 / 5
A Dockerfile review comment says: "Replace
CMD ["node", "server.js"] with ENTRYPOINT here — you want the container to always run as a Node server and allow arguments to be passed." What is the difference between CMD and ENTRYPOINT?Docker Dockerfile vocabulary — CMD vs ENTRYPOINT:
CMD
Provides default arguments for the container. Entirely overridden when you pass arguments to
ENTRYPOINT
Defines the executable. Not overridden by
Shell form vs exec form:
• Shell form:
• Exec form:
Always use exec form (JSON array) for CMD and ENTRYPOINT!
Other Dockerfile vocabulary:
•
•
•
•
•
•
•
•
•
CMD
Provides default arguments for the container. Entirely overridden when you pass arguments to
docker run:CMD ["node", "server.js"]docker run myimage python debug.py → runs python debug.py, ignoring CMDENTRYPOINT
Defines the executable. Not overridden by
docker run arguments (use --entrypoint to override):ENTRYPOINT ["node"]CMD ["server.js"]docker run myimage debug.js → runs node debug.js (uses ENTRYPOINT + passed argument instead of CMD)Shell form vs exec form:
• Shell form:
CMD node server.js → runs as /bin/sh -c "node server.js"; shell becomes PID 1 (bad for signals)• Exec form:
CMD ["node", "server.js"] → node is PID 1; receives signals directly (SIGTERM for graceful shutdown)Always use exec form (JSON array) for CMD and ENTRYPOINT!
Other Dockerfile vocabulary:
•
FROM — base image•
RUN — executes during build; creates a new layer•
COPY — copies files from build context into the image•
ADD — like COPY but also unpacks archives and fetches URLs; prefer COPY for predictability•
ARG — build-time variable (not in final image); docker build --build-arg KEY=VALUE•
ENV — runtime environment variable (baked into image layer); avoid for secrets•
EXPOSE — documentation only; does not publish ports (use docker run -p)•
WORKDIR — sets working directory for subsequent instructions; creates dir if missing•
VOLUME — declares a mount point; creates anonymous volume at runtime