Skip to main content
In this lesson we focus on how container commands and arguments (ENTRYPOINT and CMD from a Dockerfile) map into Kubernetes Pod manifests using the command and args fields. Understanding this mapping helps you control how containers start and what parameters they receive when running in a cluster.
A presentation slide titled "Application – Commands and Arguments" with the text on the left and a white list/icon set against a dark blue curved panel on the right. The slide includes a small "© Copyright KodeKloud" notice in the bottom-left.
Earlier we built a simple Docker image named 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:
Anything appended after the image name on 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:
How Dockerfile instructions relate to Kubernetes fields
  • In a Dockerfile:
    • ENTRYPOINT defines the executable that runs when the container starts.
    • CMD defines default parameters for the ENTRYPOINT (or, if no ENTRYPOINT is set, CMD can be a command to run).
  • In a Kubernetes Pod manifest:
    • command corresponds to Dockerfile ENTRYPOINT. Setting command in the manifest replaces the image’s ENTRYPOINT.
    • args corresponds to Dockerfile CMD. Setting args in the manifest replaces the image’s CMD.
You can also view this mapping in a compact table:
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"].
If you need to override both ENTRYPOINT and CMD (for example, replace the ENTRYPOINT with a hypothetical sleep2.0 command and pass 10 as its argument), include both command and args:
Mapping summary:
  • Pod command overrides Dockerfile ENTRYPOINT.
  • Pod args overrides Dockerfile CMD.
Resources and further reading: Practice by inspecting Pod YAMLs and experimenting with different command and args combinations to see how they change container startup behavior.

Watch Video

Practice Lab