This guide walks you through setting up VeilNet Conflux using Docker to enable access to container networks across multiple hosts.
Create a docker-compose.yml file with the following configuration:
services:
veilnet-conflux-1:
container_name: veilnet-conflux-1
restart: unless-stopped
env_file:
- .env
image: veilnet/conflux:beta
pull_policy: always
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
network_mode: host
Create a .env file in the same directory as your docker-compose.yml with the following variables:
VEILNET_REGISTRATION_TOKEN=<YOUR_REGISTRATION_TOKEN>
VEILNET_GUARDIAN=<YOUR_GUARDIAN_URL>
VEILNET_PORTAL=true
VEILNET_CONFLUX_TAG=<YOUR_CONFLUX_TAG>
Replace the placeholders:
<YOUR_REGISTRATION_TOKEN>: Your VeilNet registration token (obtained from the VeilNet portal)<YOUR_GUARDIAN_URL>: The URL of your VeilNet Guardian service (e.g., https://guardian.veilnet.app)<YOUR_CONFLUX_TAG>: A tag to identify this Conflux instance (e.g., dev-server, production-1)Start the VeilNet Conflux container:
docker-compose up -d
This will:
veilnet/conflux:beta image if not already presentCheck that the container is running:
docker ps | grep veilnet-conflux
View the container logs to verify it's connecting successfully:
docker logs veilnet-conflux-1 -f
You should see logs indicating successful registration and connection to the VeilNet network.
Once the VeilNet Conflux container is running, you can access containers by their container network IP addresses, even when they're running on different Docker hosts. This works because VeilNet routes traffic to container networks when the host is connected to the VeilNet overlay network.
When your Docker host is connected to VeilNet, you can access containers using their container network IP addresses from:
For example, if a container has IP 172.17.0.2 in its Docker network, you can access it directly using that IP from any other device on the VeilNet network, regardless of which physical host the container is running on.
The recommended approach for creating a service mesh with VeilNet is to have your application containers share the network namespace with the VeilNet Conflux container. This approach is recommended because:
When containers share the network namespace with veilnet-conflux:
10.128.0.5:3000), not container IPs. This eliminates the need for different CIDR ranges across hostslocalhost when on the same hostFirst, deploy VeilNet Conflux on each host using the configuration from Step 1 above.
Deploy your services using network_mode: "container:veilnet-conflux" to share the network namespace:
# docker-compose.yml on Host 1
services:
veilnet-conflux:
container_name: veilnet-conflux
restart: unless-stopped
env_file:
- .env
image: veilnet/conflux:beta
pull_policy: always
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
network_mode: host
web-app:
image: your-web-app:latest
network_mode: "container:veilnet-conflux"
depends_on:
- veilnet-conflux
api-service:
image: your-api:latest
network_mode: "container:veilnet-conflux"
depends_on:
- veilnet-conflux
environment:
- WEB_APP_URL=http://localhost:3000
# docker-compose.yml on Host 2
services:
veilnet-conflux:
container_name: veilnet-conflux
restart: unless-stopped
env_file:
- .env
image: veilnet/conflux:beta
pull_policy: always
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
network_mode: host
database:
image: postgres:15-alpine
network_mode: "container:veilnet-conflux"
depends_on:
- veilnet-conflux
environment:
- POSTGRES_DB=mydb
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
volumes:
- db-data:/var/lib/postgresql/data
volumes:
db-data:
Once all hosts are connected to VeilNet, services can communicate using the host's VeilNet IP address:
http://<host1-veilnet-ip>:<port>http://<host2-veilnet-ip>:<port>Example:
10.128.0.5 and runs a web app on port 300010.128.0.6 and runs a database on port 543210.128.0.6:543210.128.0.5:3000If you prefer to use custom Docker networks instead of network namespace sharing, you can create a service mesh by configuring each host's Docker networks with different CIDR ranges. This allows you to organize services logically while maintaining network isolation.
Important: When using custom Docker networks and accessing containers by their container IP addresses, each host MUST use different CIDR ranges to avoid IP conflicts. If two hosts use the same subnet (e.g., both use 172.17.0.0/16), containers on different hosts could have the same IP address (e.g., both could have 172.17.0.2), causing routing conflicts. This is why network namespace sharing (accessing via VeilNet IP) is recommended - it avoids this IP conflict issue entirely.
On each Docker host, create custom networks with unique, non-overlapping CIDR ranges:
Host 1:
docker network create --subnet=172.17.0.0/16 frontend-network
docker network create --subnet=172.18.0.0/16 backend-network
Host 2:
docker network create --subnet=172.19.0.0/16 frontend-network
docker network create --subnet=172.20.0.0/16 backend-network
Host 3:
docker network create --subnet=172.21.0.0/16 frontend-network
docker network create --subnet=172.22.0.0/16 backend-network
Note: Each host uses different CIDR ranges to ensure no IP conflicts when accessing containers by their container network IP addresses.
Deploy your services using these custom networks:
# docker-compose.yml on Host 1
services:
web-app:
image: your-web-app:latest
networks:
- frontend-network
networks:
frontend-network:
external: true
# docker-compose.yml on Host 2
services:
api-service:
image: your-api:latest
networks:
- backend-network
networks:
backend-network:
external: true
Once all hosts are connected to VeilNet, services can communicate using their container network IPs:
172.17.0.5 can be accessed from Host 2 using 172.17.0.5172.20.0.3 can be accessed from Host 1 using 172.20.0.3To connect multiple Docker hosts:
VEILNET_CONFLUX_TAG values to identify each instanceVEILNET_GUARDIAN URL and are registered to the same VeilNet realmWith Network Namespace Sharing (Recommended):
localhost10.128.0.5:3000), eliminating the need for different CIDR ranges per hostWith Custom Docker Networks:
To update to a newer version of VeilNet Conflux:
docker-compose pull
docker-compose up -d
The container will automatically use the updated image and reconnect to the VeilNet network.
To stop the VeilNet Conflux container:
docker-compose down
To remove the container and its configuration:
docker-compose down -v
Note: This will not remove the .env file, so your configuration will be preserved for future deployments.
The NET_ADMIN capability is required because VeilNet Conflux needs to create and manage network interfaces (TUN devices) on the host system. This capability, along with access to /dev/net/tun, allows it to establish the overlay network connection necessary for routing traffic without requiring full privileged mode.
Host network mode (network_mode: host) is used to give the container direct access to the host's network stack. This is necessary for VeilNet to properly route traffic and create the network interfaces required for the overlay network.
Yes, you can run multiple Conflux instances on the same host by:
VEILNET_CONFLUX_TAG valuesThere are two approaches:
With Network Namespace Sharing (Recommended):
10.128.0.5 and runs a service on port 3000, access it using http://10.128.0.5:3000localhostWith Custom Docker Networks:
172.17.0.2 in its Docker network, you can access it directly using that IP from any other device on the VeilNet network, regardless of which physical host the container is running on172.17.0.0/16 and Host 2 also uses 172.17.0.0/16, containers on both hosts could have the same IP (e.g., 172.17.0.2), causing routing conflictsUse network namespace sharing when (Recommended):
10.128.0.5:3000) eliminates the need for different CIDR ranges per hostlocalhostUse custom Docker networks when:
With restart: unless-stopped, Docker will automatically restart the container if it stops unexpectedly. This ensures your VeilNet connection remains available even after system reboots or container crashes.