A service must run a startup script and then the app. Should you use `CMD`, `ENTRYPOINT`, or both?
BeginnerScenarioImage design and Dockerfile decisions
Answer
Situation read → Entrypoint scripts are common for config templating or migrations.
What I'd do →
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "server.js"]
End the script with exec "$@" so the app replaces the shell and becomes PID 1.
Why → ENTRYPOINT is the fixed executable, CMD is the default, overridable argument list. Without exec, SIGTERM goes to the shell and the app is killed after the 10 s timeout.
Interview tip → Always use exec form (JSON array), never shell form, for the main process.
More on Image design and Dockerfile decisions
A teammate's Node.js image is 1.2 GB. How do you approach shrinking it?BeginnerYou need to run `apt-get install` in a Dockerfile. How do you write it so the layer stays small and cache-safe?BeginnerWhen would you pick `COPY` over `ADD`?BeginnerYour Docker build re-installs all Python dependencies on every code change. Fix it.BeginnerProduct asks for a container that runs both nginx and a Python app. What do you say?BeginnerYour app ignores `docker stop` and takes exactly 10 seconds to die. Why and what do you change?Intermediate