Compose v4: Multi-Component Applications
Deploy up to 10 components in one Flux application — internal DNS, inter-component communication, ports and environment variables.
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 specification lets you deploy up to 10 components in a single application, with automatic internal DNS for inter-component communication.
A word on the name. The compose array arrived with specification version 4, which is why multi-component deployment is still widely called "Compose v4" — the term in this article, and in the URL. The spec itself has moved on: the protocol reports latestSupportedSpecVersion: 8, enforced from block 1,932,380, and that is what a new deployment writes. Version 8 kept the compose array and added to it; nothing below is obsolete, but if a tool asks you for a version number, the answer today is 8, not 4.
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.
The current cap is 10 components per application, set by MAX_APP_COMPONENTS in the FluxOS validator. The widely-repeated figure of five is the historical limit: the validator still applies it, but only to specifications below enforcement height 6 (block 1,300,000), which the chain passed long ago — it was at block 3,114,066 on 10 November 2026. Applications with six components are live on the network today, so the five-component ceiling is simply no longer in force. If your architecture needs more than ten, combine lightweight services into one container or split into several Flux apps.
Sources & Further Reading
Measured on this site
Component count, port ranges and per-component resource ceilings come from the protocol, and they move with each specification version. The values in force are published here: Flux deployment rules.
What to read next, and why
Read Flux enterprise applications for private images, secrets, static IP, and what each surcharge really costs.
Read deploying with Git for a push, and the network redeploys.
Read Flux-Orbit for zero configuration, a hundred frameworks detected straight from your repository.
Read shared databases on Flux for replication across instances that each have their own disk.
Read the Flux app cost calculator for what a given specification costs per term.
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.