Docker Compose Tip #5: Writing Compose files for AI tools

AI tools work better when they understand the setup. Here’s how to document Compose files effectively. Add context with comments Comments help AI understand what each service does: services: # Primary web application serving React frontend # Handles user authentication and API gateway web: image: myapp:latest ports: - "3000:3000" # Public facing port - update in .env for production environment: # Connection string to PostgreSQL - format: postgresql://user:pass@host:5432/db DATABASE_URL: ${DATABASE_URL} # JWT secret for auth - must be at least 256 bits JWT_SECRET: ${JWT_SECRET} depends_on: db: condition: service_healthy # Development only - remove for production volumes: - ./src:/app/src # Hot reload for development # PostgreSQL 15 database with PostGIS extension # Stores user data and geographic information db: image: postgis/postgis:15-3.3 environment: POSTGRES_DB: myapp POSTGRES_PASSWORD: ${DB_PASSWORD} # Never commit actual password volumes: # Initial schema and seed data - ./init.sql:/docker-entrypoint-initdb.d/01-init.sql # Persistent data storage - postgres_data:/var/lib/postgresql/data volumes: postgres_data: # Named volume for database persistence across container restarts File headers For bigger projects, add a header: ...

January 9, 2026 · 3 min · 436 words · Guillaume Lours