Dockerfile instructions, layer caching, multi-stage builds, docker compose, bridge and overlay networks, volumes and registries.
41 cards · basic cards · AI-written, checked twice. Edit anything.
- What does the FROM instruction do in a Dockerfile?
Show answer
Specifies the base image from which the new image inherits
- What instruction changes the working directory inside a Dockerfile?
Show answer
WORKDIR
- What does RUN do in a Dockerfile?
Show answer
Executes a command inside the image during the build process
- What instruction copies files from the build context into the image?
Show answer
COPY
- What is the difference between COPY and ADD?
Show answer
ADD can download remote files and auto-extract archives; COPY is simpler and preferred for local files
- What does EXPOSE do?
Show answer
Documents which ports the container listens on, but does not actually publish them
- What is the difference between CMD and ENTRYPOINT?
Show answer
ENTRYPOINT specifies the main executable; CMD provides default arguments that can be overridden at runtime
- What does the USER instruction do?
Show answer
Sets the user that runs all subsequent commands and the container itself
- What instruction declares a health check for a container?
Show answer
HEALTHCHECK
- What does the ARG instruction do?
Show answer
Defines a build-time variable that can be passed with --build-arg and is not available at runtime
- Why should frequently-changed instructions be placed later in a Dockerfile?
Show answer
To preserve the cache of earlier, stable layers and speed up rebuilds
- What happens when a layer's cache is invalidated?
Show answer
All subsequent layers are rebuilt, even if their commands have not changed
- What does the --no-cache flag do when building an image?
Show answer
Forces a complete rebuild, skipping all cached layers
- How does Docker determine if a cached layer is still valid?
Show answer
By comparing checksums of the layer's commands and the contents of any source files copied into it
- What keyword enables multi-stage builds in a Dockerfile?
Show answer
FROM with an AS clause, used multiple times in the same file