command and args fields. Understanding this mapping helps you control how containers start and what parameters they receive when running in a cluster.

ubuntu-sleeper. That image runs a sleep command for a default number of seconds (5 seconds in the original example). When you run the image locally with Docker, any extra tokens you append to docker run are passed as arguments to the container process.
Example Docker runs:
docker run becomes the container’s command-line arguments. In Kubernetes Pod manifests, the equivalent is the args field (an array of strings).
Example Pod manifest that overrides the image’s default CMD by providing an argument of 10:
-
In a Dockerfile:
ENTRYPOINTdefines the executable that runs when the container starts.CMDdefines default parameters for theENTRYPOINT(or, if noENTRYPOINTis set,CMDcan be a command to run).
-
In a Kubernetes Pod manifest:
commandcorresponds to DockerfileENTRYPOINT. Settingcommandin the manifest replaces the image’sENTRYPOINT.argscorresponds to DockerfileCMD. Settingargsin the manifest replaces the image’sCMD.
Tip: Use arrays for
command and args (e.g. ["sleep", "10"]) to avoid shell interpretation differences. Kubernetes expects lists of strings for these fields and will not perform shell expansion unless you intentionally run a shell executable like ["/bin/sh", "-c", "echo hello"].sleep2.0 command and pass 10 as its argument), include both command and args:
Mapping summary:
- Pod
commandoverrides DockerfileENTRYPOINT. - Pod
argsoverrides DockerfileCMD.
- Kubernetes: Pod lifecycle and containers — https://kubernetes.io/docs/concepts/workloads/pods/
- Docker: ENTRYPOINT vs CMD — https://docs.docker.com/engine/reference/builder/#entrypoint
command and args combinations to see how they change container startup behavior.