Skip to content

skillDevOps and clouddocker

Docker Compose Development

Sets up a Docker Compose dev environment with health checks, ordered startup, sane volumes and seed data so a new teammate runs one command.

npx workspacetemplates add docker-compose-development --tool claude-code

Writes 1 file to .claude/skills/docker-compose-development/

.claude/skills/docker-compose-development/SKILL.md29 lines · 1.6 KBFile
---
name: docker-compose-development
description: Sets up a Docker Compose dev environment with health checks, ordered startup, sane volumes and seed data so a new teammate runs one command.
---

# Docker Compose development

Aim for `docker compose up` to give a working, seeded app with live reload.

## Steps

1. Read the app's start commands, ports and environment variables. List the services it needs: database, cache, queue, mail catcher.
2. Write `compose.yaml` (no `version:` key). Give each service a pinned image tag, not `latest`.
3. Add a `healthcheck` to every dependency, such as `pg_isready -U app` or `redis-cli ping`. Use `depends_on` with `condition: service_healthy` for the app.
4. Mount source code as a bind mount for reload; keep `node_modules` or the virtualenv in a named volume so the host does not overwrite it. Use named volumes for database data.
5. Put variables in `.env` and commit `.env.example`. Never commit real secrets.
6. Seed data with a one-shot service or an idempotent script (`docker compose run --rm seed`) that can run twice without duplicating rows.
7. Publish only the ports the developer needs, bound to `127.0.0.1`.
8. Add a `.dockerignore` and a multi-stage Dockerfile with a `dev` target.
9. Test it: `docker compose down -v`, then `docker compose up --build`, and confirm the app responds and the seed ran.

## Rules

- Never run containers as privileged or mount the Docker socket without saying why.
- Never use `docker compose down -v` on a developer's real data without warning; it deletes volumes.

## Report

Services, ports, the one-line start command, and how to reset the data.

What it does

A good compose file means a new developer clones the repository, runs one command and has a working app with data. A bad one starts the app before the database accepts connections and loses data every time a container restarts.

This skill builds the file around those failure points: health checks that gate startup, named volumes for state, bind mounts for code, and a seed step you can repeat safely.

Example

you › Make local setup a single command for this Rails and Postgres app

agent › Added compose.yaml with postgres:16 (healthcheck pg_isready), redis:7 and the web service waiting for healthy dependencies; bind mount for app/, named volumes for pgdata and bundle; bin/seed is idempotent. Verified from a clean state: localhost:3000 serves the seeded app in about 40 seconds.

Questions

Is this meant for production?
No. It targets local development, with bind mounts and open ports. Production images and orchestration need separate settings.
How do I reset my database?
Run docker compose down -v to remove the named volumes, then up again. The report states this so nobody does it by accident.
  • CI Pipeline Speedup

    SkillDevOps and cloud

    Free
  • Deployment Strategies

    SkillDevOps and cloud

    Free