Log In Sign Up

Docker Compose Generator

Development DevOps Claude GPT-4
4 views Added March 26, 2026

Prompt

Generate a docker-compose.yml for: Application: {application}. Services needed: {services}. Environment: {environment}. Requirements: {requirements}. Include: service definitions with proper images, environment variables (using .env references), volumes for persistence, networks for isolation, health checks, restart policies, and resource limits. Add comments explaining key decisions.

Variables

application services environment requirements

About This Prompt

Generate Docker Compose configurations from application stack descriptions with best practices.

Share

Example Output

```yaml
# docker-compose.yml — Next.js + PostgreSQL + Redis
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- '3000:3000'
environment:
- DATABASE_URL=postgresql://app:$${DB_PASSWORD}@db:5432/myapp
- REDIS_URL=redis://cache:6379
depends_on:
db:
condition: service_healthy
cache:
condition: service_started
restart: unless-stopped
volumes:
- ./:/app
- /app/node_modules

db:
image: postgres:16-alpine
environment:
POSTGRES_DB: myapp
POSTGRES_USER: app
POSTGRES_PASSWORD: $${DB_PASSWORD}
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U app -d myapp']
interval: 5s
retries: 5
restart: unless-stopped

cache:
image: redis:7-alpine
restart: unless-stopped

volumes:
pgdata:
```

Usage Tips

  • Use Alpine images for smaller footprint
  • Always add health checks for databases
  • Reference secrets via .env file
  • Pin image versions for reproducibility