---
title: "Make the container file system read-only · Agent Wranglers"
url: https://agentwranglers.se/playbook/operations/containers/read-only-containers
updated: 2026-10-20
licence: "All rights reserved"
---

# Make the container file system read-only

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

- Level: Recommended
- Chapter: [Containers](https://agentwranglers.se/playbook/operations/containers)
- Rule: Run containers with a read-only root file system. Mount a volume for data and a `tmpfs` for scratch files.
- How: An attacker who gets code running cannot then change the app or drop tools on the disk. Set `read_only: true` in Compose or `--read-only` on the command line. Give writable paths only where the app writes, such as the data volume and `/tmp`.
- Check: `docker exec web touch /app/write-test` fails with a read-only error, and the app still serves pages and writes its data.

Example:

```yaml
services:
  web:
    read_only: true
    tmpfs: [/tmp]
    volumes: [data:/data]
```

**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/read-only-containers`.

- Previous: [Let the main process receive stop signals](https://agentwranglers.se/playbook/operations/containers/container-signals)
- Next: [Declare a health check in the image](https://agentwranglers.se/playbook/operations/containers/container-health)
- [Containers](https://agentwranglers.se/playbook/operations/containers)
