agent-ready Compose guide
Docker Compose Files for Codex, Copilot, and Claude
How developers can use Docker Compose as a shared deployment contract with Codex, GitHub Copilot, Claude Code, and Defang.
Codex, GitHub Copilot, and Claude Code all work best when deployment intent is visible in the repository. Docker Compose is a practical shared contract because it is familiar to developers and structured enough for agents to edit safely.
What the Compose file should contain
A good agent-authored Compose file includes:
- One service per runtime process.
- Clear build contexts or images (Defang also supports Railpack for apps without Dockerfiles).
- Public ports only for externally reachable services.
- Health checks for services that receive traffic.
- Environment variable names, not secret values.
- Managed-service intent for databases, caches, and LLMs.
depends_ondeclarations when startup order matters.
How each agent fits
- Claude Code can read entire repo context, run commands interactively, and execute
defang compose updirectly. Best for end-to-end audit-and-deploy workflows. - Codex runs in a sandboxed environment. It excels at generating and editing the Compose file, but the user or CI pipeline runs the deployment commands.
- GitHub Copilot is primarily a code completion tool. It suggests Compose file content and explains deployment steps, but does not execute commands.
Use Defang Agent Skills
Install Defang Agent Skills for compatible coding agents so the same workflow can cover Compose review, cloud cost estimates, deployment, and debugging.
Why this helps humans
The developer can review one file and understand the deployment shape. They can ask the agent to explain or modify a service without digging through provider-specific infrastructure.
Why this helps agents
Agents can search for exact Compose concepts, apply small patches, and validate the result. They do not need to infer cloud infrastructure from scattered app files every time the user asks to deploy.
Deployable example
services:
web:
build: .
ports:
- "3000:3000"
environment:
- DATABASE_URL
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
depends_on:
db:
condition: service_started
db:
image: postgres:17
x-defang-postgres: true
Recommended path
Use compose.new to build or validate the file. Use Defang to deploy it. That keeps the AI-generated changes small, reviewable, and connected to production infrastructure.