VLAN
Enable private networking between Discloud applications using VLAN and HOSTNAME in discloud.config.
🧾 Overview
The VLAN feature lets multiple Discloud applications communicate over an isolated private network (container-to-container) without exposing internal services publicly. Typical scenarios:
Backend API
Business logic
api
app calling database
Database
Persistent storage
MongoDB / PostgreSQL template or container
Cache
Low-latency data
Redis instance
⚙️ Configuration (discloud.config)
Add the following keys to each application that should participate in the private network:
NAME=My Mongo Server
VLAN=true
HOSTNAME=mymongoserver
# | ^ |
# | Private network name for this application
VLAN
Yes
Enables private networking for the application
HOSTNAME
Recommended
Custom hostname alias for other apps to reach this one
If two apps set the same HOSTNAME, behavior is undefined. Keep hostnames unique and lowercase (letters, digits, hyphens).
🧷 Example: MongoDB Service + Backend
Service app:
NAME=Mongo Service
VLAN=true
HOSTNAME=mymongoserver
Backend connection code:
import mongoose from 'mongoose';
const uri = 'mongodb://mymongoserver:27017/mydatabase';
// ^
// HOSTNAME from Mongo service app
async function main() {
try {
await mongoose.connect(uri);
console.log('Connected to MongoDB successfully');
} catch (error) {
console.error('MongoDB connection error:', error);
process.exit(1);
}
}
main();
🧵 Hostname Conventions
Characters
a-z 0-9 -
only
Length
1–25 chars
🛡️ Security Notes
Isolation
Only apps you deploy with VLAN enabled can reach each other
Exposure
No automatic public port publishing
Secrets
Still store credentials via environment variables
Principle
Disable VLAN on apps that do not need internal reachability
Combine VLAN with environment-scoped credentials for least privilege.
Last updated