How to Create a macOS Virtual Machine Using Docker


Apple’s macOS is an aesthetic wonder, offering out-of-the-box good looks, great tools, and integration across the entire Apple ecosystem.

If you don’t want to buy Apple’s hardware, a Hackintosh or a 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 allows you to 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 an actual computer, and on which you can run any software that you would be able to run on a physical computer. You can run Windows within Linux, Linux within macOS, and any combination of these.

VMs are great for testing out new operating systems or distros, for providing tutorial screenshots, and for using OS-specific tools which 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 you to use 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 great deal of configuration. You also need to download the operating systems and go through the entire installation process.

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

Docker-OSX Makes It Easy to Instantly Create a macOS VM

Docker-OSX is a tool that allows you to spin up a macOS image almost instantly and offers near-native performance. With a single command, you can have macOS Catalina running on your desktop, or create a fresh installation of macOS Big Sur, Monterey, or Ventura. If you have got a hankering for older systems, you can use High Sierra and Mojave, too.

In case you’re worried about missing some Apple functionality, Docker-OSX supports iPhone USB passthrough, 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 VM on your Linux system, you need to have Docker installed.

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

 sudo apt install 

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

 sudo dnf install docker 

If you use Arch Linux or derivatives, run:

 sudo pacman -S docker 

Docker is now installed on your system. Start and enable 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, then back in again to save the changes.

You also need to install QEMU and some additional dependencies to ensure the virtual machine runs 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 preferred distro, 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 most straightforward option is to go with a ready-to-run macOS Catalina image. Although the OS 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 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 make a cup of tea or catalog your groceries, Docker will pull the relevant image, and when you return you will be looking at a macOS Catalina login screen. The image is configured so that you can log in straight away with the username “user”, and the password “alpine”.

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

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

Use Docker-OSX to create a clean macOS Catalina install:

 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 macOS Big Sur install:

 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 macOS Monterey install:

 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 macOS Ventura install:

 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 macOS High Sierra install, 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 macOS Mojave install 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 create macOS machines on demand with a minimum of fuss, there’s no limit to your creative options, and you can install macOS-specific apps without problems. The macOS software ecosystem is very different from what you’re used to with Linux and there isn’t nearly so much open-source software.

Take a good look around Apple’s operating system and become familiar with the most essential features to make your life easier.


Source link

Leave a Reply

%d bloggers like this: