How to Create a macOS Virtual Machine Using Docker

Apple’s macOS is a cosmetic marvel that offers good looks out of the box, great tools, and integration across the Apple ecosystem.

If you don’t want to buy Apple’s hardware, a Hackintosh or virtual machine is usually the way to go. But if you want to run macOS and you’re in a hurry, there’s no better option than Docker-OSX, which lets you instantly create any macOS virtual machine on Linux.

Why not set up a virtual machine to run macOS?

A virtual machine is the digital equivalent of a real computer, and one in which you can run any software that you could run on a physical computer. You can run Windows inside Linux, Linux inside macOS, and any combination of these.

Virtual machines are great for testing new operating systems or distributions, providing tutorial screenshots, and using OS-specific tools that don’t work well through emulation or compatibility layers.

Examples of this type of software include Adobe’s creative suite, which was originally designed to run on the Apple Macintosh and was later ported to Windows. Running Photoshop on Linux is difficult and usually requires the use of a virtual machine.

But setting up a dedicated virtual macOS machine in VirtualBox or VMware Workstation Player is a time-consuming operation, with multiple steps and a lot of configuration. You also need to download the operating systems and go through the entire installation process.

Instead of spending hours fiddling with virtual machine settings, you could be editing videos, creating cool artwork, or mixing new music.

Docker-OSX makes it easy to instantly create a macOS virtual machine

Docker-OSX is a tool that allows you to activate a macOS image almost instantly and offers near-native performance. With a single command, you can run macOS Catalina on your desktop or create a new installation of macOS Big Sur, Monterey, or Ventura. If you feel like older systems, you can also use High Sierra and Mojave.

In case you’re worried about losing some Apple functionality, Docker-OSX supports iPhone USB pass-through and allows you to share directories, files, and folders with the host system.

Get started with Docker-OSX on Linux

Before you can use Docker-OSX to quickly create a macOS virtual machine on your Linux system, you must have Docker installed.

If you are using Debian or Ubuntu, run the following command:

sudo apt install

To install Docker on Fedora, RHEL, or their derivatives:

sudo dnf install docker

If you are using Arch Linux or derivatives, run:

sudo pacman -S docker

Docker is now installed on your system. Start and activate it with:

sudo systemctl start docker
sudo systemctl enable docker

Now add your user to the docker group with:

sudo usermod -aG docker username

Log out and back in to save the changes.

You also need to install QEMU and some additional dependencies to ensure that the virtual machine works as expected. To install QEMU on Debian and Ubuntu, run:

sudo apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager libguestfs-tools

If Arch Linux is your distribution of choice, use the following command:

sudo pacman -S qemu libvirt dnsmasq virt-manager bridge-utils flex bison iptables-nft edk2-ovmf

To install QEMU on Red Hat Enterprise Linux, Fedora, CentOS, or Rocky Linux, run:

sudo yum install libvirt qemu-kvm

Next, enable libvirt and load the KVM kernel module with the following commands:

sudo systemctl enable 
sudo systemctl enable
echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs
sudo modprobe kvm

With that out of the way, you’re ready to start pulling macOS Docker images.

The easiest option is to opt for a ready-to-run macOS Catalina image. Although the operating system was only released in 2019, Apple officially stopped supporting it on November 30, 2022. Nonetheless, it’s still a relatively modern and very capable desktop that you can use to get things done.

Open a terminal and enter:

docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" -e GENERATE_UNIQUE=true sickcodes/docker-osx:auto
macOS Catalina running on Ubuntu with Docker-OSX

While you’re making a cup of tea or cataloging your purchases, Docker will pull the relevant image, and when you return, you’ll see a macOS Catalina login screen. The image is set up so that you can log in directly with the username “user” and the password “alpine”.

That’s it. A single line into your terminal and you’re running macOS with a 20 GB virtual hard drive!

While that’s certainly quick, you may want to install macOS from scratch and set your own username and password. Docker-OSX provides multiple images that can help you do this. Just open up a terminal and enter the appropriate command from below.

Use Docker-OSX to create a clean installation of macOS Catalina:

docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:latest

Use Docker-OSX to create a clean installation of macOS Big Sur:

docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:big-sur

Run the following command to create a clean installation of macOS Monterey:

docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" -e GENERATEUNIQUE=true -e MASTERPLIST_URL=''sickcodes/docker-osx:monterey

Use Docker-OSX to create a clean install of macOS Ventura:

docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" -e GENERATEUNIQUE=true -e MASTERPLIST_URL=''sickcodes/docker-osx:ventura

To create a clean installation of macOS High Sierra, run:

docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:high-sierra

Create a clean install of macOS Mojave with:

docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:mojave

Running macOS on Linux has never been easier!

Now you can build macOS machines on demand with minimal effort, there’s no limit to your creative options, and you can install macOS-specific apps seamlessly. The macOS software ecosystem is very different from what you’re used to with Linux, and there isn’t as much open source software.

Take a look at Apple’s operating system and familiarize yourself with the most essential features to make your life easier.

Leave a Reply

Your email address will not be published. Required fields are marked *