beginnerDockerfile Instructions & Multi-Stage Builds
What happens if both CMD and ENTRYPOINT are defined in a Dockerfile?
ENTRYPOINT is treated as the executable; CMD's value (each array element) is appended as arguments to it. For example, ENTRYPOINT ["java","-jar","app.jar"] with CMD ["--server.port=9090"] results in the container running java -jar app.jar --server.port=9090. Running docker run image --server.port=8081 replaces only the CMD portion.
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