✦ For everyone, free.

Practical knowledge for real and everyday life

Home

12.1.1.3 Dev Dependency Services

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

Dev dependency services are the supporting infrastructure — databases, caches, message queues — that a development environment provides through Compose, allowing an application under active development to connect to fully functional, consistently configured dependencies without requiring direct installation of any of them.

Defining the Full Set of Dependency Services Needed

A development Compose file typically defines every supporting service an application actually depends on.

services:
  app:
    build: .
    volumes:
      - .:/app
    environment:
      - DATABASE_URL=postgres://db:5432/app
      - CACHE_URL=redis://cache:6379
  db:
    image: postgres:16
  cache:
    image: redis:7

The application connects to db and cache exactly as it would in a more complete deployment, despite this entire setup running locally on a single developer's machine.

Why This Removes a Significant Setup Burden

Without this approach, a developer would need to separately install, configure, and manage a database and cache directly on their own machine — Compose-defined dependency services remove this burden entirely, providing working infrastructure with a single command.

docker compose up -d
Why Dependency Services Should Closely Match Production Versions

Using the same major version of a database or cache in development as is actually used in production reduces the risk of subtle, version-specific behavioral differences causing problems that only surface later, in a different environment.

services:
  db:
    image: postgres:16

Matching this version to production's actual PostgreSQL version helps ensure development behavior accurately reflects what will actually happen in production.

Resetting Dependency Services to a Fresh State

Dependency services can be reset to a completely clean state easily, supporting scenarios like testing a migration from scratch.

docker compose down -v
docker compose up -d
Why Dev Dependency Services Matter

Providing an application's full set of supporting dependencies through Compose removes substantial local setup burden while also helping ensure development behavior accurately reflects how the application will actually behave once deployed against equivalent infrastructure.