Compose v4: Multi-Component Applications
Deploy up to 5 components with Flux Compose v4 — internal DNS, inter-component communication, ports, and environment variables.
Compose v4: Multi-Component Applications
Real-world applications are rarely a single container. A typical web app consists of a frontend, an API backend, a database, and possibly a cache or message queue. Flux's Compose v4 specification allows you to deploy up to 5 components in a single application, with automatic internal DNS for inter-component communication.
How Compose v4 Works
In a Compose v4 spec, each component is defined as a separate entry in the compose array. Each component has its own Docker image, ports, environment variables, resources (CPU, RAM, HDD), and persistent storage. All components within the same app can communicate with each other using Flux's internal DNS system.
Internal DNS Communication
When you deploy a multi-component app, Flux automatically sets up internal DNS entries for each component. Components can reach each other using the component name as a hostname. For example, if your app has a component named api and another named db, the api component can connect to the database at db:5432 (for PostgreSQL) using the component name as the DNS hostname.
Use the component name (from the spec) as the hostname in your connection strings. Example: DATABASE_URL=postgresql://user:pass@db:5432/mydb — where "db" is the name field of your database component.
Complete Multi-Component Example
Here is a complete Compose v4 specification for a typical 3-component web application: React frontend + Node.js API + MongoDB database.
Compose v4 spec — 3-component web app
{
"version": 4,
"name": "mywebapp",
"description": "Full-stack web application",
"owner": "YOUR_ZELID",
"instances": 3,
"compose": [
{
"name": "frontend",
"description": "React frontend",
"repotag": "yourusername/myapp-frontend:latest",
"ports": [80],
"containerPorts": [80],
"domains": ["www.myapp.com"],
"environmentParameters": ["REACT_APP_API_URL=http://api:3000"],
"commands": [],
"containerData": "/usr/share/nginx/html",
"cpu": 0.5,
"ram": 256,
"hdd": 1
},
{
"name": "api",
"description": "Node.js API backend",
"repotag": "yourusername/myapp-api:latest",
"ports": [3000],
"containerPorts": [3000],
"domains": ["api.myapp.com"],
"environmentParameters": [
"NODE_ENV=production",
"MONGODB_URI=mongodb://db:27017/myapp",
"PORT=3000"
],
"commands": [],
"containerData": "/appdata",
"cpu": 1,
"ram": 512,
"hdd": 2
},
{
"name": "db",
"description": "MongoDB database",
"repotag": "mongo:7",
"ports": [],
"containerPorts": [27017],
"domains": [],
"environmentParameters": [],
"commands": [],
"containerData": "/data/db",
"cpu": 1,
"ram": 512,
"hdd": 5
}
]
}Component Configuration Fields
| Field | Type | Description |
|---|---|---|
| name | string | Component name — used as DNS hostname for inter-component communication |
| description | string | Human-readable description |
| repotag | string | Docker image in namespace/image:tag format |
| ports | number[] | Ports exposed to the public internet (leave empty for internal-only components) |
| containerPorts | number[] | Ports the container listens on internally |
| domains | string[] | Custom domains attached to this component |
| environmentParameters | string[] | KEY=VALUE environment variables |
| commands | string[] | Override container CMD / entrypoint arguments |
| containerData | string | Mount path for persistent volume |
| cpu | number | CPU cores allocated to this component |
| ram | number | RAM in MB allocated to this component |
| hdd | number | Storage in GB allocated to this component |
Key Design Patterns
- 1
Database components: no public ports
Set ports to an empty array [] for database components. They should only be accessible via internal DNS from other components, never from the public internet.
- 2
Frontend proxy to API
Configure the frontend to communicate with the API using the internal DNS hostname (e.g., api:3000). For client-side requests, use a public API domain.
- 3
Separate domains per component
Assign different domains to each public-facing component: www.myapp.com for frontend, api.myapp.com for the API.
- 4
Resource allocation
Allocate resources based on workload. Databases need more storage (hdd) and RAM; APIs need more CPU; frontends are lightweight.
Compose v4 supports a maximum of 5 components per application. If your architecture needs more, consider combining lightweight services into a single container or splitting into multiple Flux apps.
Sources & Further Reading
Other articles in FluxCloud Advanced Deployment
Docker Prerequisites & Best Practices for Flux
Install Docker, create optimized Dockerfiles, multi-stage builds, image registries, containerData volumes, and common mistakes.
Enterprise Deployments (Private Images, Secrets & Static IP)
Enterprise mode features — private Docker registries, secrets management, static IPs, node targeting, and pricing.
Deploy with Git (CI/CD & Auto-Deploy)
Auto-deploy from GitHub/GitLab/Bitbucket — webhooks, polling, zero-downtime updates, rollback, and CI/CD integration.
Flux-Orbit: Zero-Config Universal Deployment
Deploy any project without a Dockerfile — auto-detection for Node.js, Python, Rust, Go, Java, Bun, Ruby, and static sites.
Shared Databases & Auto-Replication
Deploy databases on Flux with persistent storage — MongoDB, PostgreSQL, Redis replication strategies and backup patterns.
Tiered Resources, Spec Builder & Cost Calculator
Basic/Super/BAMF resource tiers, Visual Spec Builder, Cost Calculator, pricing model, and cloud cost comparison.
App Troubleshooting & Post-Deployment Management
Diagnose deployment failures, domain issues, DB connection problems — plus updating specs, monitoring, and app lifecycle management.