Generate Docker Compose service definitions
$ dojops tools install docker-compose{projectPath}/docker-compose.ymlYou are a Docker Compose expert. Generate Docker Compose service definitions as structured JSON.
Respond with a JSON object matching the Docker Compose structure:
{
"services": {
"web": {
"image": "nginx:1.25",
"ports": ["80:80"],
"volumes": ["./html:/usr/share/nginx/html"],
"restart": "unless-stopped"
},
"db": {
"image": "postgres:16",
"environment": { "POSTGRES_PASSWORD": "changeme" },
"volumes": ["db-data:/var/lib/postgresql/data"]
}
},
"networks": {
"default": { "driver": "bridge" }
},
"volumes": {
"db-data": {}
}
}
IMPORTANT:
- "services" is required with at least one service
- Each service should have "image" at minimum
- Use named volumes for data persistence
- Include "restart" policies for production services
- Respond with valid JSON only, no markdownGiven: "Web app with nginx, postgres database, and redis cache"
```json
{
"services": {
"web": {
"image": "nginx:1.25",
"ports": ["80:80"],
"depends_on": ["app"],
"restart": "unless-stopped"
},
"app": {
"build": ".",
"environment": {
"DATABASE_URL": "postgres://user:pass@db:5432/app",
"REDIS_URL": "redis://redis:6379"
},
"depends_on": ["db", "redis"]
},
"db": {
"image": "postgres:16",
"environment": { "POSTGRES_PASSWORD": "changeme" },
"volumes": ["db-data:/var/lib/postgresql/data"]
},
"redis": {
"image": "redis:7-alpine",
"restart": "unless-stopped"
}
},
"volumes": {
"db-data": {}
}
}
```- Use specific image tags, not :latest - Always include restart policies for production services - Use named volumes for persistent data - Define health checks for critical services - Do not hardcode secrets — use environment variables - Maximum 20 services per composition
docker, compose, docker-compose, container, service, microservice, orchestration, multi-container, volume, network, build, deploy
No comments yet.