Adding the --command flag vs not adding

11/3/2019

learning kubernetes from 0, Trying to find the difference between adding the --command flag to nod adding it to this command.

kubectl run busybox --image=busybox --command --restart=Never -- env

VS

kubectl run busybox --image=busybox --restart=Never -- env

pretty much both worked for me, what am i missing ?

Wrote the output to yaml:

With --command :

- command:
  - env
  image: busybox
  name: busybox1

Without --command :

- args:
  - env
  image: busybox
  name: busybox

what is the difference between args and command ?

-- Valentin Bichok
kubernetes
kubernetes-pod

1 Answer

11/3/2019

You can always look up by

kubectl run -h

Start the nginx container using the default command (i.e command defined in Docker container manifest) , but use custom arguments (arg1 .. argN) for that command.

  kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>

Start the nginx container using a different command and custom arguments.

  kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>

If we compare with Docker:

Docker's ENTRYPOINT - executable invoked when the container is executed - maps to command in Kubernetes

Docker's CMD - arguments that get passed to the ENTRYPOINT maps to args - in Kubernetes

In your case it does not make any difference because you are not specifying any command actually (i.e. should be --command ls for example.

-- fg78nc
Source: StackOverflow