dgkanatsios / CKAD-exercises

A set of exercises to prepare for Certified Kubernetes Application Developer exam by Cloud Native Computing Foundation
MIT License
8.77k stars 5.64k forks source link

Using args #196

Closed arezk84 closed 3 years ago

arezk84 commented 3 years ago

In multi-container pod example: https://github.com/dgkanatsios/CKAD-exercises/blob/master/b.multi_container_pods.md

Why don't we use command in the init container instead of args?

As k8s docs:

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

jhchong92 commented 3 years ago

In this example, command and args can be used interchangeably.

The situation where command can yield different results is when the Docker image uses ENTRYPOINT. And using command will overwrite the ENTRYPOINT as stated in the docs:-

kubectl explain pod.spec.containers.command

... The docker image's ENTRYPOINT is used if this is not provided.

In this article, you may find some info on the topic. Also, the author wrote a gist demonstrating the difference between CMD and ENTRYPOINT in Docker, which relates to this topic as well.