Skip to main content
coding intermediate

Generate Docker Compose Configuration Files

AI prompt to create production-ready Docker Compose files for any application stack. Perfect for developers and DevOps engineers.

Works with: chatgptclaudegemini

Prompt Template

You are an expert DevOps engineer specializing in containerization and Docker Compose. I need you to create a comprehensive Docker Compose configuration file for the following application setup. **Application Details:** - Application type: [APPLICATION_TYPE] - Services needed: [SERVICES_LIST] - Environment: [ENVIRONMENT] - Special requirements: [SPECIAL_REQUIREMENTS] **Requirements:** 1. Create a complete docker-compose.yml file with proper service definitions 2. Include appropriate environment variables and configuration 3. Set up proper networking between services 4. Configure volumes for data persistence where needed 5. Include health checks for critical services 6. Follow Docker Compose best practices for [ENVIRONMENT] environment 7. Add comments explaining key configurations 8. Ensure services start in the correct order using depends_on when necessary 9. Configure proper restart policies 10. Include any necessary build contexts if custom images are needed **Additional Considerations:** - Use official images when possible - Implement security best practices - Configure logging appropriately - Set resource limits if specified - Include any proxy or load balancing setup if needed Provide the complete docker-compose.yml file with explanations for each major section. Also include a brief guide on how to run and manage this setup.

Variables to Customize

[APPLICATION_TYPE]

The type of application you're containerizing

Example: full-stack web application with React frontend and Node.js backend

[SERVICES_LIST]

List of services/components needed for your application

Example: PostgreSQL database, Redis cache, Node.js API server, Nginx reverse proxy

[ENVIRONMENT]

Target deployment environment

Example: development

[SPECIAL_REQUIREMENTS]

Any specific requirements or constraints

Example: need SSL termination, database migrations on startup, file upload storage

Example Output

```yaml version: '3.8' services: # PostgreSQL Database postgres: image: postgres:15-alpine environment: POSTGRES_DB: myapp POSTGRES_USER: ${DB_USER:-postgres} POSTGRES_PASSWORD: ${DB_PASSWORD:-password} volumes: - postgres_data:/var/lib/postgresql/data - ./init.sql:/docker-entrypoint-initdb.d/init.sql ports: - "5432:5432" restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres}"] interval: 30s timeout: 10s retries: 3 # Redis Cache redis: image: redis:7-alpine ports: - "6379:6379" restart: unless-stopped healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 30s timeout: 10s retries: 3 # Node.js API Server api: build: context: ./backend dockerfile: Dockerfile environment: - NODE_ENV=development - DATABASE_URL=postgresql://${DB_USER:-postgres}:${DB_PASSWORD:-password}@postgres:5432/myapp - REDIS_URL=redis://redis:6379 ports: - "3000:3000" depends_on: postgres: condition: service_healthy redis: condition: service_healthy restart: unless-stopped volumes: - ./backend:/app - /app/node_modules volumes: postgres_data: networks: default: driver: bridge ``` **Usage Guide:** 1. Create a `.env` file with your environment variables 2. Run `docker-compose up -d` to start all services 3. Use `docker-compose logs -f` to monitor logs 4. Stop with `docker-compose down`

Pro Tips for Best Results

  • Always specify image versions instead of using 'latest' tags for production environments
  • Use .env files to manage environment variables and keep secrets out of your compose file
  • Include health checks for databases and critical services to ensure proper startup order
  • Use named volumes for data that needs to persist between container restarts
  • Test your compose file in development before deploying to production environments

Tags

Want 500+ Expert Prompts?

Get the Premium Prompt Pack — organized, tested, and ready to use.

Get it for $29

Related Prompts You Might Like