Features
Snapshots and images
Snapshots are APFS copy-on-write copies of the disk: instant, and they only take space as the disk changes.
Snapshots
hangar snapshot take <vm> <name>
hangar snapshot list <vm>
hangar snapshot restore <vm> <name>
hangar snapshot delete <vm> <name>For take the name is optional; it defaults to the date and time. delete takes several names at once.
Taken while a macOS VM runs, a snapshot also keeps its memory, so a restored VM resumes where it was (this needs the Mac to be unlocked). Linux and Windows snapshots are disk only: Virtualization can't restore their memory with the USB keyboard and pointer they need.
Clones
A snapshot also works as a starting point: new VMs made from it start up fresh, with their own MAC address, IP address and machine identity, while the source keeps running.
hangar snapshot take base clean
hangar clone base web1 --snapshot clean
hangar clone base web2 --snapshot cleanShare a VM through a registry
Push a macOS, Linux or Windows VM (or one of its snapshots) to a registry your team uses, and create VMs from it anywhere by its tag. It's a good way to hand everyone the same CI environment: the image stays private in your registry, and since it's an OCI image, the container registry you already run takes it with no extra setup.
hangar export base ghcr.io/acme/ci-linux:1.0 --snapshot clean
hangar create ci1 --os linux --image ghcr.io/acme/ci-linux:1.0The whole disk goes into the image, with its accounts, password hashes and SSH host keys, so clean it up first. On Linux also empty
/etc/machine-idso each VM gets its own.
Linux VMs made from an image get new SSH host keys and their own name through cloud-init on their first start. Pulling a newer image of the same repository replaces the older one in the cache; VMs already made from it keep working.
Sign in to a private registry first; the token is kept in your Keychain:
hangar login ghcr.io -u <name>Images are OCI images, so registries such as GitHub, GitLab, Docker Hub, Harbor and Quay take them. Downloads that stop carry on where they stopped, and --chunk-size <mb> uploads in pieces for registries that limit request size.
For a registry without HTTPS, add --insecure to the hangar command: your sign-in then travels in the clear and a tag can be changed on the way, though every part is still checked against the image's digest.
Share a VM as a file
Without a registry, save the image to a file and create VMs from that; a value ending in .tar is always a file.
hangar export base ~/ci-linux.tar
hangar create ci1 --os linux --image ~/ci-linux.tar