Skip to content
Back to skills

Docker Compose Patterns

ASecurity

Use when orchestrating multi-service Docker environments.

  • 2 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 10, 2026
ai-agentsgoshellbashsqlnodedockerapifrontendbackend

Works with

  • api

Security analysis

A100/100

Scanned September 10, 2026

npx -y skills add LoopyLuci/Skills --skill docker-compose-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Docker Compose Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Docker Compose Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/loopyluci-docker-compose-patterns/badge)](https://www.skillsdirectory.com/skills/loopyluci-docker-compose-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: docker-compose-patterns
description: "Use when orchestrating multi-service Docker environments."
category: docker
tags: [docker, compose, orchestration, yaml]
---

# Docker Compose Patterns

Common, production-grade Docker Compose patterns for dev environments and multi-service architectures.

## Basic Structure

```yaml
version: "3.9"
services:
  app:
    build: .
    ports: ["3000:3000"]
    volumes: [".:/app", "/app/node_modules"]
    depends_on: { db: { condition: service_healthy } }
  db:
    image: postgres:16-alpine
    volumes: ["pgdata:/var/lib/postgresql/data"]
    healthcheck: { test: ["CMD-SHELL", "pg_isready"], interval: 10s }
volumes: { pgdata: }
```

## Profiles

```yaml
services:
  app: { profiles: ["base", "dev", "prod"] }
  mailhog: { profiles: ["dev"] }
  prometheus: { profiles: ["monitoring"] }
# docker compose --profile dev up -d
```

## DRY Anchors

```yaml
x-logging: &log { driver: "json-file", options: { max-size: "10m" } }
services:
  web: { image: nginx, logging: *log }
  api: { image: myapi, logging: *log }
```

## Init Containers

```yaml
services:
  app: { image: myapp, depends_on: [db-migrate] }
  db-migrate:
    image: myapp; entrypoint: ["npm", "run", "migrate"]
    depends_on: { db: { condition: service_healthy } }
```

## Networks

```yaml
services:
  api: { networks: [frontend, backend] }
  db: { networks: [backend] }
networks:
  frontend: {}
  backend: { internal: true }
```

## Commands

```powershell
docker compose up -d --build
docker compose down -v --rmi all
docker compose logs -f; docker compose exec app bash
docker compose run --rm app npm test
docker compose config; docker compose build --parallel
```

## Pitfalls

- **depends_on** waits for start, not readiness — use `condition: service_healthy`
- **$VAR** in compose — escape with `$$` for literal `$`
- **.env** is auto-loaded — don't commit it
- **v2** is current; v1 (docker-compose) deprecated

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.