---
title: "Run the same images locally with Compose · Agent Wranglers"
url: https://agentwranglers.se/playbook/operations/containers/compose-for-local
updated: 2026-10-20
licence: "All rights reserved"
---

# Run the same images locally with Compose

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Containers](https://agentwranglers.se/playbook/operations/containers)
- Rule: 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: 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.
- 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.

Example:

```yaml
services:
  web:
    build: .
    init: true
    read_only: true
    tmpfs: [/tmp]
    env_file: .env
    ports: ["8080:8080"]
  db:
    image: postgres:17.6-alpine
```

**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`.

- Previous: [Run one process per container](https://agentwranglers.se/playbook/operations/containers/one-process-per-container)
- [Containers](https://agentwranglers.se/playbook/operations/containers)
