kubectl run --command vs -- arguments kubectl run --command vs -- arguments kubernetes kubernetes

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 the EntryPoint field in Docker
  • the args field in Kubernetes corresponds to the Cmd field in Docker

From Kubernets documentation:

When you override the default Entrypoint and Cmd, these rules apply:

  • If you do not supply command or args for a Container, the defaultsdefined in the Docker image are used.

  • If you supply a command but no args for a Container, only the suppliedcommand is used. The default EntryPoint and the default Cmd defined inthe Docker image are ignored.

  • If you supply only args for a Container, the default Entrypointdefined in the Docker image is run with the args that you supplied.

  • If you supply a command and args, the default Entrypoint and thedefault Cmd defined in the Docker image are ignored. Your command isrun with your args.


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