This directory contains practical examples showing different ways to use dockvirt with the new, simplified API.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π₯οΈ HOST SYSTEM β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β dockvirt CLI β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β π config.py β β π₯ image_ β β π§ vm_ β β
β β (config) β β manager.py β β manager.py β β
β β β β (download) β β (create VM) β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β ~/.dockvirt/ β
β βββ π config.yaml (configuration) β
β βββ π images/ (OS image cache) β
β βββ π vm_name/ (cloud-init files) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π libvirt/KVM β
β βββ virt-install β creates VM β
β βββ virsh β manages VM β
β βββ qemu-kvm β runs VM β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π₯οΈ VIRTUAL MACHINE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π§ Ubuntu/Fedora + cloud-init β
β βββ π³ Docker Engine β
β βββ π¦ docker-compose β
β βββ π Caddy (reverse proxy :80/:443) βββ β
β βββ π± Your App Container β β
ββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββββββββ
β
βΌ
π http://app.local
flowchart TD
A[π dockvirt up] --> B{π config.yaml exists?}
B -->|β No| C[π Create default config]
B -->|β
Yes| D[π Load configuration]
C --> D
D --> E{πΌοΈ OS image local?}
E -->|β No| F[π₯ Download from internet]
E -->|β
Yes| G[πΎ Use local]
F --> |β³ wget/curl| G
G --> H[π§ Render cloud-init]
H --> I[πΏ Create cloud-init ISO]
I --> J[π½ Create VM disk]
J --> K[β‘ virt-install]
K --> L[π³ VM + Docker + Caddy]
L --> M[π Application available!]
style A fill:#e1f5fe
style M fill:#c8e6c9
style F fill:#fff3e0
All examples have been updated to use the latest features:
.qcow2 files~/.dockvirt/config.yaml with predefined settings--base-image and --os-variant, just use --osTip: Prefer the local repository venv binary to ensure the latest CLI:
# From repository root
make install
source .venv-3.13/bin/activate
dockvirt --help
# Or invoke explicitly without activating:
.venv-3.13/bin/dockvirt --help
flowchart LR
A[π HTML + CSS] --> B[π³ Docker build]
B --> C[π dockvirt up]
C --> D[π₯ Ubuntu download]
D --> E[β‘ VM creation]
E --> F[π Nginx serving]
F --> G[π http://static-site.local]
style A fill:#f9f9f9
style G fill:#c8e6c9
Example flow:
Developer Docker dockvirt libvirt Browser
β β β β β
ββ build βββββ β β β β
β ββ nginx:alpine β β β
ββ dockvirt up ββββββββββββββββ β β β
β β ββ download βββ β β
β β β ubuntu.img β β
β β ββ virt-install β β β
β β β ββ VM + Docker β
β β β ββ Caddy proxy β
β β β β β
ββ add /etc/hosts βββββββββββββββββββββββββββββββββββββββββ β
β β β β ββ GET /
β β β β β
flowchart TD
A[π Python Flask App] --> B[π requirements.txt]
B --> C[π³ Dockerfile]
C --> D[π¨ docker build]
D --> E{π₯οΈ Choose OS}
E -->|Ubuntu| F[π dockvirt up]
E -->|Fedora| G[π΅ dockvirt up --os fedora38]
F --> H[π Flask + Caddy]
G --> H
H --> I[π http://flask-app.local]
style A fill:#306998
style I fill:#c8e6c9
System comparison:
Ubuntu 22.04 Fedora 38
β β
ββ apt-get update ββ dnf update
ββ install docker ββ install docker
ββ pip install requirements ββ pip install requirements
ββ docker compose up ββ docker compose up
β β
ββ ~2-3 min startup ββ ~2-4 min startup
flowchart TD
A[βοΈ ~/.dockvirt/config.yaml] --> B{π₯οΈ OS Selection}
B -->|ubuntu22.04| C[π Ubuntu VM]
B -->|fedora38| D[π΅ Fedora VM]
B -->|debian12| E[π£ Debian VM]
B -->|custom| F[βͺ Custom VM]
C --> G[π Performance Test]
D --> G
E --> G
F --> G
G --> H[π Results Comparison]
style A fill:#fff3e0
style H fill:#c8e6c9
System configuration:
βββββββββββββββββββββββββββββββββββββββββββ
β ~/.dockvirt/config.yaml β
βββββββββββββββββββββββββββββββββββββββββββ€
β default_os: ubuntu22.04 β
β images: β
β ubuntu22.04: β
β url: https://cloud-images.ubuntu... β
β variant: ubuntu22.04 β
β fedora38: β
β url: https://download.fedora... β
β variant: fedora38 β
β debian12: # Your configuration β
β url: https://cloud.debian.org... β
β variant: debian12 β
βββββββββββββββββββββββββββββββββββββββββββ
# Check if all dependencies are installed
dockvirt check
# If something is missing, install automatically
dockvirt setup --install
# Go to any example
cd examples/1-static-nginx-website
# Build the Docker image
docker build -t my-static-website:latest .
# Just run - the parameters are in the .dockvirt file
dockvirt up
# Run with default Ubuntu 22.04
dockvirt up \
--name my-test \
--domain my-test.local \
--image example-app:latest \
--port 80
# Or choose Fedora
dockvirt up --os fedora38
# .dockvirt
name=my-app
domain=my-app.local
image=my-app:latest
port=80
os=ubuntu22.04
Before running the examples, make sure you have:
dockvirt installed: pip install dockvirtdockvirt checkdockvirt setup --install# Test all examples on different OS
python ../scripts/test_examples.py
# Test only one example
python ../scripts/test_examples.py 1-static-nginx-website
# The test report will be saved in test_results.md
.dockvirt file with default parameters.dockvirt to change the VM name, port, or OSdockvirt down --name <name> to remove a VMdockvirt ip --name <name> to check the VMβs IPdockvirt ip --name <vm_name>
If you test HTTP by IP with Caddy/reverse proxy inside the VM, include a Host header:
curl -H 'Host: app.local' http://<ip>/
By default, libvirt NAT (network=default) is used. To make VMs visible in your LAN, use a Linux bridge (e.g., br0).
sudo nmcli con add type bridge ifname br0 con-name br0
sudo nmcli con add type bridge-slave ifname enp3s0 master br0
sudo nmcli con modify br0 ipv4.method auto ipv6.method auto
sudo nmcli con up br0
dockvirt up --net bridge=br0
.dockvirt:net=bridge=br0
With bridge networking, VMs receive a LAN IP and are visible to other machines on your network.
Note: Do not run
makeordockvirtwithsudo. Tools will request sudo only when necessary and act on your real HOME.
The test script checks:
If you encounter problems:
sudo systemctl status libvirtdvirsh console <vm-name>cat ~/.dockvirt/config.yamlls -la ~/.dockvirt/images/