Hi, I have a question about using command: command: ["sh", "-c", "sleep 600"] v . . .

dxloader:
Hi, I have a question about using command:

command: [“sh”, “-c”, “sleep 600”]
vs
command: [“sleep”, “600”]

what is the difference? which one is better ?

R Banerjee:
sleep 600 wont work if the image you are working upon doesnt load up with bash/sh

For example, if you have Prometheus Image, then prometheus CLI would be loaded as the entry point. If you need to login to the container’s shell, you need exec -it $POD_NAME -- sh , to load the shell. Similarly, here sh -c is a way to tell the container to load the shell and then execute 600s sleep.

Logically , no container ideally should give a default shell , because then anyone can login and it can be a security issue( imagine logging and doing an rm -rf :stuck_out_tongue: )

1 Like

R Banerjee:
Point is, it depends what the entry command is. Logically, the first one is better since it takes care if the entry command is sh or non-sh

1 Like

thanks for the detailed explanation !