ENTRYPOINT และ CMD ต่างก็กำหนดสิ่งที่จะรันเมื่อ container เริ่มต้น แต่ทั้งสองมีบทบาทต่างกันและทำงานร่วมกันในรูปแบบเฉพาะ การเข้าใจความแตกต่าง (และรูปแบบสองแบบ — exec กับ shell) เป็นเรื่องสำคัญต่อการเขียน Dockerfile ที่ทำงานได้ถูกต้อง
CMD — คำสั่งเริ่มต้น (override ได้)
CMD ["node", "server.js"]
# → the DEFAULT command when the container starts
# → but it's REPLACED if you pass a command at run time:
# docker run myapp echo hello → runs "echo hello" INSTEAD of node server.js
ให้ ซึ่งจะถูก ด้วยคำสั่งใด ๆ ที่ระบุตอน
