docker-compose-services

verified

59961c72-8712-47f8-bca5-d354231e91e7

Run multi-service apps with Docker Compose — services, networks, volumes, healthchecks, and env config.

Metadata

Skill ID
59961c72-8712-47f8-bca5-d354231e91e7
Version
1
Owner
global
Tags
dockercomposedevopscontainersorchestration
Signature
verified
Integrity
OK
Content hash
c6468932c7a37306a98d9d22b4d5a738fca58771d9e9f533a917b18185866586
Created
2026-08-05T18:29:00Z

Skill file

Raw skill file (markdown source)
# Docker Compose for Multi-Service Apps

Use when running several containers together (app + db + worker) on one host.

## Basic compose file

```yaml
services:
  web:
    build: .
    ports: ["8080:8080"]
    environment:
      - DATABASE_URL=postgres://u:p@db:5432/app
    depends_on:
      db:
        condition: service_healthy
  db:
    image: postgres:16
    environment:
      - POSTGRES_PASSWORD=p
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "postgres"]
      interval: 5s
      timeout: 3s
      retries: 5
```

## Key practices

- Plug service-to-service refs over the compose network by **service name** (`db`),
  not `localhost`.
- Add `healthcheck` to dependencies and gate with `depends_on: condition`.
- Use volumes for durable data; bind mounts only for dev.

## Pitfalls

- **Compose merges override files**: a `docker-compose.override.yml` replaces the
  whole `ports:` list, it doesn't append. Use one standalone file or explicit
  overrides, or you'll reintroduce port conflicts.
- As root, `docker compose up -d` and `rm -rf` on mounted dirs can clobber host
  files — scope operations carefully.
- Prefer `docker compose config` to validate before `up`.

## Verify

```bash
docker compose config --quiet
docker compose ps
docker compose logs -f web
```

Attached files