✦ For everyone, free.

Practical knowledge for real and everyday life

Home

9.1.2 Compose Dev Infrastructure

A focused guide to Compose Dev Infrastructure, connecting core concepts with practical Docker and container operations.

Compose dev infrastructure refers to using a Compose file specifically to stand up the supporting services a developer needs locally — databases, caches, message queues — without needing to install and manage each of these dependencies directly on their own machine.

A Typical Development Infrastructure Setup

A Compose file defines just the supporting infrastructure a developer needs, often run alongside an application that itself runs directly on the host (outside a container) during active development.

services:
  db:
    image: postgres:16
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_PASSWORD=devpassword
  redis:
    image: redis:7
    ports:
      - "6379:6379"
docker compose up -d

A developer can now run their application directly on their own machine, connecting to these containerized dependencies running locally, without needing to install PostgreSQL or Redis directly on their system at all.

Why This Approach Is Convenient for Development

Avoiding direct installation of supporting infrastructure keeps a developer's machine clean, makes it trivial to reset a service to a fresh state, and ensures every developer on a team uses identically configured versions of these dependencies.

docker compose down -v
docker compose up -d

This quickly resets the database (and any other infrastructure) to a completely fresh state, something considerably more involved with a directly installed database.

Running Multiple Independent Projects Without Conflict

Different projects, each with their own Compose file defining their own infrastructure, can run independently on the same machine without port or configuration conflicts, as long as port mappings are chosen to avoid collisions between simultaneously running projects.

docker compose -p project-a up -d
docker compose -p project-b up -d
Why Compose Dev Infrastructure Matters

Using Compose specifically to provide a project's supporting infrastructure locally is a widely adopted, convenient pattern that significantly simplifies local development setup, avoiding the overhead and potential conflicts of installing and managing multiple databases, caches, and other dependencies directly on a developer's own machine.

Content in this section