default arguments for an ENTRYPOINT or a default command that can be easily overridden.
Defines the primary executable that will always run when the container starts.
Overriding
Easily overridden by any command/arguments provided after the image name in docker run.
Not easily overridden by runtime arguments; new arguments are appended to the ENTRYPOINT command. To override, you must use the --entrypoint flag in docker run.
Combining
When combined with ENTRYPOINT (in exec form), CMD defines the default arguments for that executable.
When combined with CMD (in exec form), ENTRYPOINTdefines the fixed command.
Usage
Use when you want to provide a sensible default but allow users to easily run different commands.
Use when you want your container to behave like a specific executable (e.g., a CLI tool).
WORKDIR
Equivalent to cd
The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADDinstructions that follow it in the Dockerfile.
If the WORKDIR doesn’t exist, it will be created even if it’s not used in any subsequent Dockerfile instruction.