ubuntu-sleeper image that demonstrates how ENTRYPOINT and CMD from a Dockerfile map to the command and args fields in a Pod spec.
Table of Contents
- Recap: ubuntu-sleeper Docker Image
- Create a Pod with the Default Command
- Override CMD with
args - Override ENTRYPOINT with
command - Summary & Mapping Table
- References
Recap: ubuntu-sleeper Docker Image
We built a minimal Docker image called ubuntu-sleeper:- Running without extra arguments uses the default sleep duration (5 seconds):
- Providing an argument overrides
CMD(for example, sleep 10):
CMD instruction.
Create a Pod with the Default Command
Here’s the simplest Pod manifest that runssleep 5 by default:
ENTRYPOINT + CMD (sleep 5), and the container will exit after 5 seconds.
Override CMD with args
To change the sleep duration without touching the entrypoint, specify an args array in your Pod spec:
sleep 10. Update the Pod:
The
args field in Kubernetes corresponds directly to the Dockerfile CMD. Any elements you list here will override the default CMD values.Override ENTRYPOINT with command
If you need to override both the entrypoint and its arguments, use the command field for the entrypoint and args for its parameters:
commandreplaces the DockerfileENTRYPOINT.argsreplaces the DockerfileCMD.
If you override the
command field, make sure the specified executable exists in the container filesystem. Otherwise, the Pod will fail to start.Summary & Mapping Table
The table below summarizes how Dockerfile instructions map to Kubernetes Pod spec fields:| Dockerfile Instruction | Kubernetes Pod Spec Field | Purpose |
|---|---|---|
| ENTRYPOINT | command | Defines the executable to run |
| CMD | args | Provides default parameters/arguments |