I have written like this : command: [“sh”,“-c”,“perl -Mbignum=bpi -wle ‘print bpi(1024)’”] and also verified the k logs, it’s also printing the output. But the simulator marked as failed.
Which one is right?
command: [“sh”,“-c”,“perl -Mbignum=bpi -wle ‘print bpi(1024)’”]
or
command: [“perl”, “-Mbignum=bpi”, “-wle”, “print bpi(2000)”]
There are multiple valid ways to define commands and arguments within a Kubernetes container.
The default entrypoint for many minimal images like BusyBox and Alpine is /bin/sh
, which means the container starts with a shell and then waits for further instructions. Because of this, it’s often fine to omit sh -c
unless your command requires shell processing (such as using pipes or shell-specific features).
You can also define the command and arguments like this:
text
command: ["/bin/sh"]
args: ["-c", "perl -Mbignum=bpi -wle 'print bpi(1024)'"]
Or, if you want to call the executable directly by splitting the command as separate elements ( as in the lab’s solution)
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
Both styles are valid, but the validation in the labs is looking for syntax like the one above.