This example demonstrates using dockvirt to run a complex microservices stack with multiple VMs.
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend VM β β Backend VM β β Database VM β
β β β β β β
β React App βββββΊβ Node.js API βββββΊβ Redis + Postgresβ
β app.stack.local β β api.stack.local β β db.stack.local β
β β β β β β
β Ubuntu 22.04 β β Fedora 38 β β Ubuntu 22.04 β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ
β Monitoring VM β
β β
β Grafana + Prom β
β mon.stack.local β
β β
β Ubuntu 22.04 β
βββββββββββββββββββ
# Build Docker images first
docker build -t microstack-frontend:latest ./frontend
docker build -t microstack-api:latest ./api
docker build -t microstack-db:latest ./database
docker build -t microstack-monitoring:latest ./monitoring
# Developer tip: ensure you use the local repo CLI from the venv if another dockvirt is on PATH
# ../../.venv-3.13/bin/dockvirt --help
# Or activate the venv:
# source ../../.venv-3.13/bin/activate
# Frontend
dockvirt up --name frontend --domain app.stack.local --image microstack-frontend:latest --port 3000 --os ubuntu22.04
# Backend API
dockvirt up --name backend --domain api.stack.local --image microstack-api:latest --port 8080 --os fedora38
# Database
dockvirt up --name database --domain db.stack.local --image postgres:latest --port 5432 --os ubuntu22.04
# Monitoring
dockvirt up --name monitoring --domain mon.stack.local --image grafana/grafana:latest --port 3000 --os ubuntu22.04
# Deploy the entire stack with one command
dockvirt stack deploy microservices-stack.yaml
# Build all components
make build-all
# Or individually
docker build -t microstack-frontend:latest ./frontend/
docker build -t microstack-api:latest ./backend/
docker build -t microstack-db:latest ./database/
docker build -t microstack-monitoring:latest ./monitoring/
name=frontend
domain=app.stack.local
image=microstack-frontend:latest
port=3000
os=ubuntu22.04
mem=2048
name=backend
domain=api.stack.local
image=microstack-api:latest
port=8080
os=fedora38
mem=4096
name=database
domain=db.stack.local
image=microstack-db:latest
port=5432
os=ubuntu22.04
mem=4096
disk=50
name=monitoring
domain=mon.stack.local
image=microstack-monitoring:latest
port=3000
os=ubuntu22.04
mem=2048
After startup, add the following to /etc/hosts:
<IP_FRONTEND> app.stack.local
<IP_BACKEND> api.stack.local
<IP_DATABASE> db.stack.local
<IP_MONITORING> mon.stack.local
Then open:
Tip: If a reverse proxy (Caddy) is used inside the VM, IP-based HTTP checks may require a Host header. For quick checks by IP:
curl -H 'Host: app.stack.local' http://<ip_frontend>/
curl -H 'Host: api.stack.local' http://<ip_backend>/
curl -H 'Host: mon.stack.local' http://<ip_monitoring>/
Grafana dashboards are available at http://mon.stack.local:
# Test the entire stack
curl http://api.stack.local/health
curl http://app.stack.local/api/status
# Load testing
ab -n 1000 -c 10 http://api.stack.local/api/users
# Monitoring test
curl http://mon.stack.local/api/health
name: Deploy Microservices Stack
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup DockerVirt
run: |
pip install dockvirt
dockvirt check
- name: Build Images
run: make build-all
- name: Deploy Stack
run: |
dockvirt stack deploy microservices-stack.yaml
- name: Health Check
run: |
sleep 60 # Wait for VMs to boot
curl -f http://api.stack.local/health
curl -f http://app.stack.local/
# Remove all VMs from the stack
dockvirt down --name frontend
dockvirt down --name backend
dockvirt down --name database
dockvirt down --name monitoring
# Or with a single command (planned)
dockvirt stack destroy microservices-stack
Problem: Services cannot communicate
Solution: Check if all VMs are on the same libvirt network
Problem: No external access
Solution: Check /etc/hosts and make sure the VMs have been assigned IPs
Note: Do not run
dockvirtormakewithsudo. The tools request sudo only when needed and act on your real HOME.
Problem: High latency
Solution: Increase the VMβs RAM or use SSD storage