Skip to main content
AIPromptIndex
Cursor Coding intermediate

Docker Compose Generator for Multi-Service Apps

Added Apr 2, 2026

Generate a production-ready Docker Compose configuration for a [APP_TYPE] application with the following services: [SERVICES_LIST]. The deployment environment is [ENVIRONMENT]. Create a complete docker-compose.yml that includes: properly configured services with official base images and pinned version tags (never use 'latest'), health checks for every service with appropriate intervals and retries, a named network with proper service isolation (not all services need to talk to each other), named volumes for persistent data with explicit mount paths, environment variables loaded from a .env file with sensible defaults, resource limits (memory and CPU) appropriate for each service, restart policies suited to each service's criticality, proper dependency ordering with depends_on and health check conditions. Also generate: a companion .env.example file with all variables documented, a Dockerfile for the application service if it needs a custom build, a .dockerignore file, and brief setup instructions. Add comments in the compose file explaining non-obvious configuration choices. Ensure the configuration follows the Compose Specification (v3.8+). Flag any security concerns like running containers as root or exposed debug ports.
0
Share
Try in Cursor

About This Prompt

This prompt generates Docker Compose configurations that follow production best practices out of the box, saving you from the hours of trial-and-error that typically accompany multi-service setups. Every service gets health checks, resource limits, and proper networking — the details that are easy to skip but critical for reliability. The companion .env.example and .dockerignore files mean your team can clone and run without configuration archaeology. The security audit catches common mistakes like exposed ports and root containers before they reach production. Whether you are setting up a local development environment or deploying to a Docker Compose-based production setup, this prompt produces configurations that work correctly the first time.

Variables to Customize

[APP_TYPE]

The type of application being containerized

Example: full-stack SaaS application

[SERVICES_LIST]

The services that need to run together

Example: Next.js frontend, Node.js API, PostgreSQL database, Redis cache, Nginx reverse proxy, and Celery worker with RabbitMQ

[ENVIRONMENT]

Where this will be deployed

Example: local development with hot-reloading, with a separate production override file

Tips for Best Results

  • Specify your exact technology versions so Cursor pins the right image tags
  • Ask for a docker-compose.override.yml for development-specific settings like volume mounts and debug ports
  • Include your current Dockerfile if you have one so Cursor can optimize it alongside the compose config

Example Output

```yaml
# docker-compose.yml
# Full-stack SaaS application - Development Configuration
# Compose Specification v3.8

version: '3.8'

services:
  # --- Application Layer ---
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
      target: development
    ports:
      - "3000:3000"
    volumes:
      - ./frontend/src:/app/src  # Hot-reload source files
    environment:
      - NEXT_PUBLIC_API_URL=http://localhost:4000
    depends_on:
      api:
        condition: service_healthy
    networks:
      - frontend-net
    deploy:
      resources:
        limits:
          memory: 512M
          cpus: '0.5'
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  api:
    build:
      context: ./api
      dockerfile: Dockerfile
    # ... continued
```
docker docker-compose devops containerization infrastructure

Get the Best AI Prompts Weekly

Curated prompts, tips, and guides delivered to your inbox every week. Free.