Have you failed a job interview?
Send us your job interview questions and get correct answers.

What is the CMD instruction good for in Docker?

Experience Level: Senior
Tags: Docker


The main purpose of a CMD is to provide defaults for an executing container. These defaults can include an executable, or they can omit the executable, in which case you must specify an ENTRYPOINT instruction as well.

If CMD is used to provide default arguments for the ENTRYPOINT instruction, both the CMD and ENTRYPOINT instructions should be specified with the JSON array format.

The CMD instruction has three forms:

Form 1 (exec form, this is the preferred form)

CMD ["executable","param1","param2"] 

Form 2 (as default parameters to ENTRYPOINT)

CMD ["param1","param2"]

Form 3 (shell form)

CMD command param1 param2 


No Comments Yet.
Be the first to tell us what you think.
Docker instructions
Docker instructions

Are you learning Docker ? Try our test we designed to help you progress faster.

Test yourself