OPS-61Recommended
Run one process per container
Give each container one main process, and read every setting from the environment.
How to do it
A web server, a worker and a database each get their own container, so each can restart, scale and log on its own. The same image then runs in every environment, as the settings rule asks. Set memory and CPU limits per container, as with any service.
How to check
docker top web lists one main process plus the init process. The same image starts in staging and production with only different variables.
Sources
Related rules
- ENG-22 Keep settings outside the code in Engineering
- OPS-34 Set limits on memory and processes in Operations and observability
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/operations/containers/one-process-per-container">Agent Wranglers operations and observability playbook</a>. In code you write, add a comment next to it with the same link.