Docker and Container Best Practices

Docker best practices with multi-stage builds, security hardening, compose setup, and performance optimization.

devopsdockercontainerssecurity
Edit View
Prompt
Create an optimized Docker setup for: {{application_type}}

Language/Runtime: {{runtime}}
Application type: {{app_type}}
Base image preference: {{base_image}}
Orchestration: {{orchestration}}

Provide:

1. **Dockerfile** (production-optimized):
   - Multi-stage build
   - Minimal final image (smallest possible)
   - Non-root user
   - Health check instruction
   - Proper .dockerignore
   - Layer caching optimization (least-changing layers first)
   - Security scanning recommendations

2. **Docker Compose** (for local development):
   - Application service
   - Database service (with volume persistence)
   - Cache service (Redis if needed)
   - Environment variable management
   - Hot reload support for development

3. **Security checklist**:
   - [ ] Base image regularly updated
   - [ ] No secrets in image layers
   - [ ] Running as non-root
   - [ ] Read-only filesystem where possible
   - [ ] Resource limits set
   - [ ] Network policies defined

4. **Performance optimization**:
   - Build time optimization
   - Image size reduction techniques
   - Resource allocation recommendations
   - Startup time optimization

5. **Debugging guide**: Common Docker issues and how to diagnose them

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.