Containers Recommended
Run the same images locally with Compose
Describe the local setup in one Compose file that uses the production images and versions, so the app runs the same way on every laptop.
How to do it
Build the app from the same Dockerfile, and pin every other service, such as the database, to the version production runs. Keep secrets in a local .env file that .dockerignore and version control both leave out. Use docker compose watch to rebuild on changes.
Example
services:
web:
build: .
init: true
read_only: true
tmpfs: [/tmp]
env_file: .env
ports: ["8080:8080"]
db:
image: postgres:17.6-alpine
How to check
On a clean machine, docker compose up --wait exits 0 once every service is healthy, and the database reports the same major version as production.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers operations playbook: https://agentwranglers.se/playbook/operations/containers/compose-for-local.