kubectl run --command vs -- arguments
When working with containers in Kubernetes, you should be careful not to mix up Kubenetes command
and Docker Cmd
.
- the
command
field in Kubernetes corresponds to theEntryPoint
field in Docker - the
args
field in Kubernetes corresponds to theCmd
field in Docker
From Kubernets documentation:
When you override the default
Entrypoint
andCmd
, these rules apply:
If you do not supply
command
orargs
for a Container, the defaultsdefined in the Docker image are used.If you supply a
command
but noargs
for a Container, only the suppliedcommand
is used. The defaultEntryPoint
and the defaultCmd
defined inthe Docker image are ignored.If you supply only
args
for a Container, the defaultEntrypoint
defined in the Docker image is run with theargs
that you supplied.If you supply a
command
andargs
, the defaultEntrypoint
and thedefaultCmd
defined in the Docker image are ignored. Yourcommand
isrun with yourargs
.
In this example, yes both are same. Lets say if an entry point (command) is set as sleep 1000
but if your args are set as sleep 3000
then container command is ignored and sleep 3000
is executed.
Args takes precedence over command, and overrides command values if args exists