advancedTop 100 Interview Questions

Why is exec form preferred over shell form for CMD/ENTRYPOINT?

Exec form (`["java","-jar","app.jar"]`) runs the process directly as PID 1, so it receives signals like SIGTERM correctly for graceful shutdown. Shell form (`java -jar app.jar`) wraps the command in `/bin/sh -c`, making the shell PID 1 and the actual process a child that may not receive signals properly, breaking graceful shutdown.

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

Next Step

Continue to What is the difference between ARG and ENV?← Back to all Docker questions