This example shows how to run a simple Python Flask application using dockvirt.
Start the VM with dockvirt:
The Dockerfile and application files will be automatically copied to the VM and built there:
Use the .dockvirt file for maximum convenience:
# Build happens inside the VM automatically.
# Optional (not required): pre-build on host
# docker build -t my-flask-app:latest .
# Use the default configuration from the .dockvirt file
dockvirt up
# Developer tip: if another dockvirt is first on your PATH (e.g., Homebrew),
# use the project venv binary explicitly to ensure the latest local CLI:
# ../../.venv-3.13/bin/dockvirt up
# Or change the OS to Fedora (edit .dockvirt or use the parameter)
dockvirt up --os fedora38
You can also ignore the .dockvirt file and use full parameters:
# Full command with parameters
dockvirt up \
--name flask-app \
--domain flask-app.local \
--image my-flask-app:latest \
--port 5000 \
--os ubuntu22.04
/etc/hosts:
After getting the IP address from dockvirt, add it to your /etc/hosts file:
<ip_address> flask-app.local
If a reverse proxy (Caddy) is used inside the VM, IP-based checks may require a Host header:
curl -H 'Host: flask-app.local' http://<ip_address>/
Open the application in your browser:
Visit http://flask-app.local to see your application.
dockvirt down --name flask-app
Note: Do not run
dockvirtormakewithsudo. The tools request sudo only when needed and act on your real HOME.
On the first run, dockvirt will automatically download the required operating system image:
~/.dockvirt/images/jammy-server-cloudimg-amd64.img~/.dockvirt/images/Fedora-Cloud-Base-38-1.6.x86_64.qcow2Images are cached locally, so subsequent runs will be much faster.
When you run dockvirt up, the tool:
Use the local CLI from the repository venv to retrieve the VM IP:
../../.venv-3.13/bin/dockvirt ip --name flask-app
If you test HTTP via IP and use a reverse proxy (Caddy) inside the VM, include a Host header:
curl -H 'Host: flask-app.local' http://<ip>/
By default, libvirt NAT (network=default) is used. To expose the VM directly in your LAN, create a bridge (e.g., br0) and run:
../../.venv-3.13/bin/dockvirt up --net bridge=br0
Persist per project by adding to .dockvirt:
net=bridge=br0
Example bridge creation (Fedora/NetworkManager):
```bash 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