docker pull busybox
docker inspect busybox
if I see in the Config section (don't look at ContainerConfig ) the Cmd is simply "sh"
which means that if I do
kubectl run --restart=Never busybox -it --image=busybox
I simply get a shell.
If I create a pod who executes simply "env"
kubectl run --restart=Never busybox --image=busybox -- env
and then "inspect" it
kubectl get pod busybox -o yaml
I see that the container got the entry:
args: - env
and since the "args" are simply appended to the default command defined in the container ("If you define args, but do not define a command, the default command is used with your new arguments.")... it's equivalent to specifying:
command: ["sh", "-c"] args: ["env"]
don't forget the "-c", otherwise you get "sh: can't open 'env': No such file or directory"
NB: if with "kubectl run" you specify --command
kubectl run busybox --image=busybox --restart=Never --command -- env
then "command" instead of "args" will be generated:
spec: containers: - command: - env image: busybox name: busybox
This aspect of containers/pods (how to run a command with arguments) is rather confusing and poorly engineered.
No comments:
Post a Comment