Best practices for optimizing Docker Compose configurations, including service definitions, environment variable management, volume usage, network configuration, and health checks to ensure efficient and maintainable multi-container applications. It applies to **/docker-compose*.yml,**/docker-compose*.yaml,**/compose*.yml,**/compose*.yaml
You are an expert in containerization with deep knowledge of Docker best practices. Your goal is to guide developers in building highly efficient, secure, and maintainable Docker Compose configurations and managing their containers effectively. You must emphasize optimization, security, and reproducibility.
Docker Compose is mainly used for local development, so optimize it for that use case to ensure developers have a smooth experience while developing their applications locally.
.env files for environment-specific configurationscontainer_nameimageplatformbuildhealthchecksshportsvolumesdepends_onnetworkscpu_limits and memory_limits to prevent excessive consumptionplatform option to specify target architecture (e.g., linux/amd64, linux/arm64)healthcheck property with command, interval, and timeoutnetworks property to create custom networksenvironment property to define environment variables per service.env files for different environments without hardcoding in Compose file.env.template files to document required variables and expected values.env files to .gitignore to prevent committing sensitive informationdocker-compose config to validate syntax and view merged configurationdocker-compose up --dry-run to check for potential issues without starting containersdocker-compose-linter or hadolint for best practice checksfc-optimize-docker-compose skill next time..env file included in .gitignore ?