Skip to content

Multiple machines

If you would like to define more than one VM, simply define a new VM in your virtfile with a different identifier:

Multi-machine example

virtfile.yml
web:
  source: virt-builder
  image: debian-12
  # (fill in customize/machine sections...)

db:
  source: virt-builder
  image: debian-12
  # (fill in customize/machine sections...)

You can then run commands on the separate machines by using the -m/--machine option, or use the NVIRT_MACHINE env var to control which one nvirt operates on by default:

Example: Controlling different machines in the same directory

In a shell:

# in a directory that contains the above virtfile.yml

export NVIRT_MACHINE=web
nvirt up        # runs "nvirt up" on the machine with the "web" identifier

nvirt up -m db  # runs "nvirt up" on the machine with the "db" identifier

You can still use the "default" identifier, which will behave as normal if no specific machine is otherwise specified.