advancedDocker & Docker Compose
What's the practical difference between `CMD` and `ENTRYPOINT` in a Dockerfile for a Spring Boot app?
`ENTRYPOINT` defines the fixed command that always runs (e.g. `java -jar app.jar`), while `CMD` supplies default arguments that CAN be overridden at `docker run` time. A common pattern sets `ENTRYPOINT` to the java invocation and leaves `CMD` empty or for default JVM flags, so operators can override just the flags without needing to know or repeat the full java command.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response