πŸš€ DevOps Certified Professional
πŸ“… Starting: 1st of Every Month 🀝 +91 8409492687 | 🀝 +1 (469) 756-6329 πŸ” Contact@DevOpsSchool.com

Complete referenece of dockerfile cmd and entrypoint

DevOps

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

What is the benefit of using CMD?

CMD instruction can be used to set default command to execute when we run docker container. It allows the user to execute some particular command while running docker container.

Docker file has CMD echo "This is test"
docker run -it 7de4bed89922 
This is test

docker run -it 7de4bed89922 /bin/bash
root@7de4bed89922:/#

What is the benefit of using ENTRYPOINT?

ENTRYPOINT instruction allows you to configure a container that will run as an executable. It has two forms – exec and shell

Exec form allows to set commands and parameters and then use either form of CMD to set additional parameters that are more likely to be changed. Where as shell form ignores any CMD or docker run command line arguments

Difference between CMD and ENTRYPOINT

CMDENTRYPOINT
CMD commands can be overwritten during docker runENTRYPOINT commands cannot be overwritten
Parameters passed are replaced Parameters passed is appended