---
name: docker-compose-file-creator
description: "A valid docker-compose.yml that brings up your app with its database and helper services, with networks, volumes, and health checks wired correctly for local development. Use when a developer needs a docker-compose file to run an app with a database and supporting services locally. Do not use for production orchestration on Kubernetes or writing the Dockerfile. Related topics: devops, docker, coding."
---

# Docker Compose File Creator

A valid docker-compose.yml that brings up your app with its database and helper services, with networks, volumes, and health checks wired correctly for local development.

## When to use

Use this skill when a developer needs a docker-compose file to run an app with a database and supporting services locally. Do not use it for production orchestration on Kubernetes or writing the Dockerfile.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. List the services needed and decide which ports and volumes each exposes.
3. Write the compose file with a named network, pinned image tags, and named volumes if requested.
4. Add healthchecks and depends_on conditions so the app starts after its database is ready.
5. Move credentials to an env file and provide a sample with placeholder values.
6. Give the up, logs, and down commands, noting how to remove volumes.

## Inputs

- **Main app service (build path or image)** (free text, e.g. "build dot or image myapp:latest")
- **Port mapping (host:container)** (free text, e.g. "8080:80")
- **Database** (choose one: None, PostgreSQL, MySQL, MongoDB, Redis)
- **Other services** (choose any: Nginx reverse proxy, RabbitMQ, ElasticSearch, Mailhog)
- **Persistent volumes for data** (choose one: Yes, No)

## Output

The docker-compose.yml, a sample .env file, and a short list of run and teardown commands.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Docker Compose File

Write a docker-compose.yml for the stack below.

- Main app service (build path or image): {{Main app service (build path or image)}}
- Port mapping (host:container): {{Port mapping (host:container)}}
- Database: {{Database}}
- Other services: {{Other services}}
- Persistent volumes for data: {{Persistent volumes for data}}

Output a complete, valid docker-compose.yml with a named network and, if volumes are requested, named volumes for each data service. Use pinned image tags, not latest. Add healthchecks to the database and make the app wait with depends_on and a healthy condition. Read credentials from an env file and show a sample .env with placeholder values, never real secrets. Expose only the ports the host needs. Comment each service, then give the commands to start, view logs, and tear down including how to remove volumes.

## Pitfalls

- Using the latest tag, so a pull changes the database version under existing data.
- Using depends_on without a health condition, so the app starts before the database accepts connections.
- Publishing the database port to the host when only the app needs it.
