This tutorial will guide you through the process of running macOS Mojave in a VM using Vagrant. I’ve mainly used this for development and testing of Ansible playbooks targeted at configuring headless app builders for iOS devices and Macs.

This tutorial assumes you have a working installation of macOS Mojave or later running on a Mac, and that you have VirtualBox and the VirtualBox Extension Pack installed. This tutorial will make use of macinbox by bacongravy.

Since the macOS EULA only allows running macOS VMs on a genuine Mac, you’ll need an iMac, MacBook Pro, Mac Mini or other Mac.

Install Vagrant

Install Homebrew and then install Vagrant:

$ /usr/bin/ruby -e "$(curl -fsSL"
$ brew install vagrant

Get the macOS Mojave Installer Application

Follow this link to go to the Mac App Store and download and install the macOS Mojave Installer.

Get the macOS Vagrant Box Builder

Install macinbox using gem, the Ruby package manager:

$ sudo gem install macinbox

Create the macOS Vagrant Box

Create a directory to store your macOS Vagrant related files, and

$ mkdir ~/macos-vagrant
$ cd ~/macos-vagrant
$ sudo macinbox # will take a while
$ vagrant init macinbox

Finally, to start the VM with Vagrant, run:

$ vagrant up

To destroy the virtual machine, simply run (while standing in the directory of your Vagrantfile, in our example ~/macos-vagrant):

$ vagrant destroy

Last Words

When this article was published macOS Catalina had already been released. I’ll update the site with instructions on how to run Catalina as well. I’ll also post a tutorial on using Ansible to configure macOS.

If you’d like to learn more about Vagrant, see the documentation, or read a book or two.

Best of luck! 😀