CMD
is used to provide defaults for an executing container. There can only be a single CMD
instruction in a Dockerfile
. If more than one, the last one will take effect.
# *exec* form, preferred one
CMD ["executable", "param1", "param2"]
# As default parameters to *ENTRYPOINT*
CMD ["param1", "param2"]
# *shell* form
CMD command param1 param2
Here, if CMD
is used to provide default arguments for ENTRYPOINT
instruction, both CMD
and ENTRYPOINT
instructions should be specified with the JSON array format.
Note: The exec form is parsed as JSON array, so you must use double-quotes (”) around the words.
FROM ubuntu
CMD echo "This is just a echoing text."
FROM ubuntu
CMD ["/usr/bin/wc", "--help"]