Skip to main content
In this tutorial, you’ll learn how to configure commands and arguments in a Kubernetes Pod. We’ll use a simple 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

  1. Recap: ubuntu-sleeper Docker Image
  2. Create a Pod with the Default Command
  3. Override CMD with args
  4. Override ENTRYPOINT with command
  5. Summary & Mapping Table
  6. 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):
In Docker CLI, anything after the image name replaces the CMD instruction.

Create a Pod with the Default Command

Here’s the simplest Pod manifest that runs sleep 5 by default:
Apply the Pod:
By default, Kubernetes uses the image’s 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:
This runs 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:
  • command replaces the Dockerfile ENTRYPOINT.
  • args replaces the Dockerfile CMD.
Apply this configuration:
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: Use these fields to precisely control the process invoked inside your containers.

References

Watch Video