---
title: "Use Docker and Docker Compose for · Agent Wranglers"
url: https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/docker-and-compose
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Use Docker and Docker Compose for containers

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

For AI agents: [llms.txt](https://agentwranglers.se/llms.txt) is a short guide that sends you to the rules your problem needs, and [rules.json](https://agentwranglers.se/playbook/stack/rules.json) holds every rule of this playbook as JSON.

- Level: Recommended
- Chapter: [Delivery and infrastructure](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure)
- Rule: Package each service as a Docker image built from a Dockerfile, and describe the local stack in one Compose file.
- Cost: Open source. Docker Engine and Compose are Apache-2.0. Docker Desktop is paid for larger companies.
- How: Docker reached 1.0 in 2014. Docker Engine 29.9.2 shipped on 20 October 2026 and Compose 5.6.1 on 21 October 2026. Both are open source under the Apache-2.0 licence. Docker is the most used cloud development tool in the Stack Overflow Developer Survey 2026, at 59.1%. Images follow the open OCI format, so they run on any container platform. Docker Desktop is proprietary and needs a paid plan for companies with 250 or more employees or 10 million dollars or more in yearly revenue. Docker Engine on Linux is free for everyone. Build images as [Pin each base image by digest](https://agentwranglers.se/playbook/operations/containers/pinned-base-images) says. Choose something else when you need containers without a root daemon. Then use Podman, which reads the same Dockerfiles.
- Check: `docker compose up` starts the whole stack from a fresh clone with no other setup step. Every Dockerfile pins its base image by version and digest.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Dockerfile example

```dockerfile
FROM node:22.23-bookworm-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
USER node
CMD ["node", "server.js"]
```

### YAML example

```yaml
services:
  app:
    build: .
    ports: ["8080:8080"]
    environment:
      DATABASE_URL: postgres://app@db/app
  db:
    image: postgres:18
```

## Sources

- [Docker documentation](https://docs.docker.com/)
- [Docker Desktop licence](https://docs.docker.com/subscription/desktop-license/)

## Related rules

- [Run the same images locally with Compose](https://agentwranglers.se/playbook/operations/containers/compose-for-local) in Operations
- [Pin each base image by digest](https://agentwranglers.se/playbook/operations/containers/pinned-base-images) in Operations

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/docker-and-compose">Agent Wranglers software choices playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Use GitHub Actions for continuous integration](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/github-actions-ci)
- Next: [Use OpenTofu for infrastructure as code](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure/opentofu)
- [Delivery and infrastructure](https://agentwranglers.se/playbook/stack/delivery-and-infrastructure)
