You are misunderstanding the relationship between command
and args
The command that the question is asking you to run would be entered to a linux terminal like this
sh -c "The app is running! && sleep 3600"
So in a pod definition that is
command:
- sh
- -c
- echo The app is running! && sleep 3600
Now, if you know that the docker image being used in the pod was built with an ENTRYPOINT
instruction, then that is the command
. That command may or may not require some additional arguments. This is when args
is used, to pass more arguments to the command which is already present in the image.
You may have seen the image kodekloud/webapp-color
in the labs. This has a dockerfile that looks like this. Note that it has an ENTRYPOINT
. This means that without you having to specify it in the pod definition, it is implicitly
command:
- python
- app.py
Now let’s suppose that python program could accept additional arguments on the command line (it doesn’t but it would be easy to change it so it does), i.e
python app.py --color blue
then the pod definition would have no command, but would have
args:
- --color
- blue
Get it yet?
In terms of images that you’re using for these challenges, know that all base images - those which are simply a Linux distro without any specific software (nginx, redis etc), do not have an embedded ENTRYPOINT
. So that’s images like busybox
, alpine
, ubuntu
etc. - these require a command otherwise they’ll immediately exit and go into crashloop.
If you put a command, then use only command
. Do not additionally put args
.