Commands and Arguments
CMD
Command that will start the container process:
Similar to CMD but higher priority
If ENTRYPOINT and CMD are used together then the ENTRYPOINT will run first.
Usually when used together the ENTRYPOINT would be the command and CMD the argument, Example:
Kubernetes Example
apiVersion: v1
kind: Pod
metadata:
name: command-demo
labels:
purpose: demonstrate-command
spec:
containers:
- name: command-demo-container
image: debian
command: ["printenv"]
args: ["HOSTNAME", "KUBERNETES_PORT"]
- name: echo-demo
image: debian
env:
- name: MESSAGE
value: "hello world"
command: ["/bin/echo"]
args: ["$(MESSAGE)"]
restartPolicy: OnFailure
Note:
You can only use onecommand
andargs
per container.
To try both examples, comment/uncomment the relevant lines or create two containers in the pod. 2 containers running is not recomended in production unless its side-container or container that will start another container.
env: - name: MESSAGE value: "hello world" command: ["/bin/echo"] args: ["$(MESSAGE)"]
start pod