An entrypoint script is an executable startup script that launches an application inside a container. Docker runs it at container runtime through CMD, not during image construction. Using a script instead of placing the application command directly in CMD leaves room for startup logic, such as checking database availability or adapting configuration. section 5.3.4
A containerized entrypoint script typically:
- Reads runtime configuration from environment variables, such as PORT, and supplies a fallback when no value exists. section 5.3.4
- Runs the application using the executable and arguments appropriate to its runtime. section 5.3.4 section 5.4.1
Python and Node.js entrypoints
A Python entrypoint sets RUNTIME_PORT to PORT or 8080, then runs Gunicorn with UvicornWorker, main:app, and a bind address using that port. A Node.js entrypoint can simply run node /app/src/main.js when the application already reads PORT itself. section 5.4.1
Do not confuse an entrypoint script with Docker's ENTRYPOINT directive. CMD can invoke the script while keeping the container configuration straightforward; the script itself remains the place for application-specific startup behavior. section 5.3.4
