I was just browsing the docs for PodSpec and noticed that for the .spec.containers.args field it says:
The container image’s CMD is used if this is not provided.
This got me wondering how this unfolds when setting command for a container where the image has CMD is set. Are args automatically unset when setting command or should I manually set args: [] just to be sure it won’t take some default values from the container?
Say I have this Dockerfile built and tagged as my-image:
FROM ubuntu
ENTRYPOINT ["/bin/bash", "-c"]
CMD ["foo=(bar); echo ${foo[0]}"] # This is valid in Bash but not in sh
Then, considering this Pod spec:
---
apiVersion: v1
kind: Pod
metadata:
name: example
spec:
containers:
- command: ["sh", "-c"]
image: my-image
name: example
Would this cause sh -c to be executed (valid) or sh -c 'foo=(bar); echo ${foo[0]}' (invalid) when the container starts? ![]()
It seems like the OCI spec does not define this, so perhaps it depends on the container runtime?