ENTRYPOINT
What is ENTRYPOINT?
ENTRYPOINT: The fixed executable a container always runs. Arguments from docker run (and CMD) are appended to it. ENTRYPOINT sets the fixed program a container always runs. Arguments from docker run, or from CMD, are added to it. With ENTRYPOINT ["php", "artisan"] and CMD ["serve"], the container runs php artisan serve by default, and docker run myapp migrate runs php artisan migrate.
Frequently asked questions about ENTRYPOINT
How is ENTRYPOINT used in practice?
This makes an image behave like a command-line tool with a sensible default action.
What should you keep in mind with ENTRYPOINT?
A common pattern is an entrypoint shell script that prepares things, such as waiting for the database or setting permissions, and ends with exec "$@" to run the actual command. The exec is important: it makes your application the main process, so it receives stop signals and shuts down cleanly. Use the JSON array form for both instructions to avoid an extra shell in between.
What does an example of ENTRYPOINT look like?
ENTRYPOINT ["python", "manage.py"] CMD ["runserver"] At a glance
| Category | Docker |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |