ENTRYPOINT định nghĩa executable chính của container. CMD cung cấp default arguments hoặc command mặc định có thể override khi chạy container. Dùng cùng nhau khi image có một binary chính và cần default args.
Ví dụ:
ENTRYPOINT ["python", "-m", "app"]
CMD ["--host", "0.0.0.0", "--port", "8000"]Nếu image là tool CLI, ENTRYPOINT giúp người dùng truyền args ngắn gọn.
Nếu image cần linh hoạt command, chỉ dùng CMD có thể dễ override hơn.
ENTRYPOINT defines the main executable of the container. CMD provides default arguments or a default command that can be overridden at runtime. They work well together when the image has one main binary and default args.
Example:
ENTRYPOINT ["python", "-m", "app"]
CMD ["--host", "0.0.0.0", "--port", "8000"]For CLI tool images, ENTRYPOINT makes passing args ergonomic.
For images that need flexible commands, only using CMD can be easier to override.