A little experiment involving Hackintosh, Docker-OSX, QEMU, KVM, a lot of troubleshooting, and eventually finding something much better.
The idea
I wanted to run macOS on my machine. There wasn't a particular use case behind it, no application I desperately needed, and definitely no plans of switching to macOS as my daily driver. I was simply curious.
Naturally, the first thing I considered was Hackintosh. For those unfamiliar with it, Hackintosh is essentially the process of installing macOS on non-Apple hardware. There's a fairly large community around it, with people managing to run macOS on all sorts of hardware, provided the right combination of components and configurations.
I started looking into hardware compatibility, OpenCore configurations, and the usual Hackintosh documentation. Unfortunately, my hardware wasn't a particularly good candidate. I even tried pushing beyond what was realistically supported, hoping I could get something working, but eventually had to accept that it wasn't worth spending more time fighting hardware compatibility.
I use Arch Linux with a minimal i3WM setup, and I wanted to keep my existing installation untouched. Repartitioning disks, setting up dual boot, or making permanent changes just for an experiment didn't sound particularly appealing. What I wanted was an isolated macOS installation that I could boot whenever I needed it and shut down when I was done.
A virtual machine seemed like the obvious solution. I just wanted to manage the whole thing through Docker.
Enter Docker-OSX
While looking for ways to run macOS in a virtualized environment, I came across Docker-OSX. It was pretty much what I was looking for: a project that packages a macOS virtual machine into a Docker-based workflow.
There's an important distinction here. Docker isn't running the macOS kernel inside a container. Docker-OSX uses QEMU and KVM to virtualize the entire macOS system, while Docker provides the environment in which that virtualization stack runs. OpenCore handles the boot process and helps present the virtual hardware to macOS.
The setup looks something like this:
- Arch Linux is the host operating system.
- Docker provides the isolated environment.
- QEMU handles virtualization.
- KVM provides hardware-assisted virtualization.
- OpenCore handles the boot process.
- X11 forwarding or VNC provides access to the guest display.
One thing I particularly liked was the ability to keep the macOS installation in a separate disk image. The mac_hdd_ng.img file could be reused across container launches, meaning I wouldn't have to go through the installation process every time.
I could keep the image somewhere in my project directory, mount it into Docker, and boot macOS without touching my existing Arch installation. That was exactly the kind of setup I wanted.
Building the macOS image
I initially thought getting macOS to boot would be the difficult part. However, building the actual disk image turned out to be a considerably bigger exercise.
I was using the naked image provided by Docker-OSX and wanted to build my own mac_hdd_ng.img using Catalina. Unlike the preconfigured images, this approach required me to handle the base installation process myself.
There was quite a bit of manual configuration involved. I had to understand what was happening inside the container, how Docker-OSX's scripts worked, how QEMU was being invoked, and what was required to get the macOS installer running.
I spent a fair amount of time configuring things inside the container before I could get the base installation working properly. This was probably the most educational part of the experiment because it pushed me beyond the usual Docker workflow of pulling an image and running a container.
I started exploring container filesystems, mounted volumes, environment variables, device access, networking, and how processes inside a container interact with the host. Instead of repeatedly restarting the container with different arguments, I wanted to inspect its environment directly.
For that, I used:
--entrypoint /bin/bash This allowed me to enter the container and inspect its filesystem, execute commands, modify configurations, and figure out what was happening behind the scenes. Of course, changes made inside a container aren't necessarily persistent, particularly when using --rm, but that wasn't a concern while experimenting.
I also spent time understanding the VNC setup. I initially wanted to use X11 forwarding, but experimented with running QEMU through VNC and connecting to it from my host. This meant looking into how the VNC server was exposed, how Docker port mappings worked, and how QEMU's display options were configured.
Eventually, I managed to get the base macOS installation working and had my own disk image ready to reuse. That was a good milestone because the installation was now separate from the container itself.
Getting it running
With the disk image ready, launching macOS became considerably easier. I had downloaded the Docker-OSX image from my (not so legal) sources and renamed it locally for convenience:
samay15jan/docker-osx:naked I kept the macOS disk image separately and started with a fairly simple Docker command:
docker run -it --rm \ --device /dev/kvm \ -v "/home/samay15jan/Mac/mac_hdd_ng.img:/image" \ --name hackintosh \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ -e RAM=8 \ -e WIDTH=1920 \ -e HEIGHT=1200 \ -e MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist" \ samay15jan/docker-osx:naked The important part here is exposing /dev/kvm to the container so QEMU can use hardware-assisted virtualization. I'm also mounting the macOS disk image at /image, forwarding the host's X11 socket, and passing some basic configuration through environment variables, including RAM allocation and display dimensions.
I ran the command, and macOS booted. Seeing an entire macOS desktop running on my Arch Linux installation through a Docker command was quite satisfying.
I also experimented with VNC as an alternative to directly forwarding the display through X11. The additional arguments were:
-p 5901:5901 \ -e EXTRA="-vnc :1" And on the host:
vncviewer localhost:5901 This gave me another way to access the guest and experiment with different display configurations. At this point, the basic setup was working, but there were still quite a few things I wanted to fix.
The problems
Getting the virtual machine to boot was one thing; getting it to behave like a usable desktop environment was another. Audio, graphics acceleration, resolution, CPU allocation, and USB passthrough were some of the areas I spent time experimenting with.
Audio was one of the first things I tried to fix. Since the guest was running through QEMU, I needed to figure out how to pass the host's audio server into the container and configure QEMU to use it. I experimented with forwarding the PulseAudio socket, mounting it inside the container, and passing the relevant environment variables.
Graphics were more complicated. The display worked, but that didn't mean the guest had GPU acceleration. I tried exposing the host's graphics devices through /dev/dri, hoping QEMU would be able to make better use of the available hardware. However, passing a GPU device into a container doesn't automatically make it usable by the guest. macOS still needs a compatible virtual graphics device and a driver that understands it.
Resolution was another annoyance. My display runs at 1920x1200, but macOS kept getting stuck at 1920x1080. Passing WIDTH and HEIGHT through Docker-OSX didn't necessarily mean the guest would recognize those modes. The resolution configured for the virtual display and the modes available inside macOS are not quite the same thing.
I also wanted more control over CPU allocation and experimented with QEMU's CPU topology options, including sockets, cores, and threads. Alongside that, I tried different USB passthrough configurations and virtual USB controllers to see how much of the host hardware I could expose to the guest.
As I worked through these issues, the Docker command kept getting longer. Eventually, I started looking beyond the environment variables Docker-OSX provided and experimenting with QEMU arguments directly.
Experimenting with QEMU arguments
Docker-OSX allows additional QEMU arguments to be passed through the EXTRA environment variable. This gives you considerably more control over the virtual machine, and I started experimenting with CPU topology, USB controllers, SPICE, virtual tablets, and display-related options.
One of my experimental configurations looked something like this:
-e EXTRA="-smp 8,sockets=1,cores=8,threads=1 \ -device virtio-serial-pci \ -device usb-host,hostbus=1,hostport=2.3 \ -monitor telnet::45454,server,nowait \ -serial null \ -spice port=3001,disable-ticketing \ -device ich9-usb-ehci1,id=usb \ -device ich9-usb-uhci1,masterbus=usb.0,firstport=0,multifunction=on \ -device ich9-usb-uhci2,masterbus=usb.0,firstport=2 \ -device ich9-usb-uhci3,masterbus=usb.0,firstport=4 \ -device usb-tablet" This wasn't a final working configuration. I was trying to configure the virtual hardware manually rather than relying entirely on the defaults.
I also experimented with exposing graphics-related devices:
--device /dev/dri/card1 \ --device /dev/dri/renderD128 \ --device /dev/vfio/vfio \ --group-add video This didn't solve graphics acceleration, but it helped me understand the distinction between exposing host devices to a container and making those devices usable by a virtual machine.
The more I worked with Docker-OSX, the more I realised that understanding QEMU was just as important as understanding Docker. Docker was providing the environment, but the virtual hardware, display, CPU configuration, and most of the things I was trying to fix were controlled by QEMU.
I ended up with multiple versions of the Docker command saved in my notes. One of my closest attempts at a complete configuration looked like this:
docker run -it \ --name hackintosh \ --device /dev/kvm \ --device /dev/dri/card1 \ --device /dev/dri/renderD128 \ --device /dev/vfio/vfio \ --group-add video \ -v "/home/samay15jan/Mac/mac_hdd_ng.img:/image" \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ -e WIDTH=1920 \ -e HEIGHT=1200 \ -e SMP=8 \ -e CORES=8 \ -e CPU_STRING="8,cores=8,threads=1,sockets=1" \ -e RAM=8 \ -e MASTER_PLIST_URL="https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist" \ samay15jan/docker-osx:naked It still wasn't perfect, but it represented quite a bit of trial and error. By this point, I had a much better understanding of what Docker-OSX was doing under the hood and how much of the setup was actually being handled by QEMU.
Making a proper startup script
Maintaining these long Docker commands was getting tedious, so I eventually wrote a startup script. I wanted it to check for the required files and devices, create the necessary directories, configure audio if possible, and launch the virtual machine. I also wanted a shared directory between the host and guest for transferring files.
My directory structure looked roughly like this:
MAC/ ├── Image/ │ └── mac_hdd_ng.img ├── shared/ ├── start.sh └── new-start.sh Here's the more organized version of the script I had saved:
#!/bin/bash set -e ROOT="$HOME/Projects/OS/MAC" IMAGE="$ROOT/Image/mac_hdd_ng.img" SHARE="$ROOT/shared" PLIST="https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist" PULSE="/run/user/$(id -u)/pulse/native" # Workspace command -v i3-msg >/dev/null 2>&1 && i3-msg "workspace 2" # Validation [[ -f "$IMAGE" ]] || { echo "Missing macOS image"; exit 1; } [[ -e /dev/kvm ]] || { echo "KVM unavailable"; exit 1; } mkdir -p "$SHARE" # Ensure Docker image exists docker image inspect samay15jan/docker-osx:naked >/dev/null # Audio availability AUDIO_ARGS=() if [[ -S "$PULSE" ]]; then AUDIO_ARGS+=( -v "$PULSE:/tmp/pulseaudio.socket" -e "AUDIO_DRIVER=pa,server=unix:/tmp/pulseaudio.socket" -e "PULSE_SERVER=unix:/tmp/pulseaudio.socket" ) fi docker run -it --rm \ --name hackintosh \ --device /dev/kvm \ --shm-size=2g \ -p 50922:10022 \ -v "$IMAGE:/image" \ -v "$SHARE:/mnt/hostshare" \ -v /tmp/.X11-unix:/tmp/.X11-unix \ "${AUDIO_ARGS[@]}" \ -e "DISPLAY=${DISPLAY:-:0.0}" \ -e RAM=6 \ -e SMP=8 \ -e CORES=8 \ -e CPU_STRING="8,cores=8,threads=1,sockets=1" \ -e WIDTH=1920 \ -e HEIGHT=1200 \ -e MASTER_PLIST_URL="$PLIST" \ samay15jan/docker-osx:naked The script kept the disk image outside the container, mounted the shared directory at /mnt/hostshare, and mapped port 50922 to 10022 for SSH access. It also checked whether KVM was available and whether the disk image and Docker image existed before launching anything.
For audio, I added a check for the host's PulseAudio socket and passed it into the container if available. These were experimental audio settings rather than a guarantee that the entire audio pipeline was working.
I also added a small i3-msg command to switch to workspace 2 before launching the VM. Since I was using i3WM, having a dedicated workspace for the virtual machine made the setup a little more convenient.
The desktop environment situation
I was using i3WM on Xorg, so the X11 integration was relatively straightforward. Mounting /tmp/.X11-unix and forwarding the DISPLAY variable was enough to get the graphical output working.
I had also considered trying the same setup with Hyprland, but that introduced another layer of complexity. XWayland provides compatibility for X11 applications under Wayland, although that doesn't guarantee every display configuration will behave as expected. I didn't particularly want to spend more time troubleshooting the compositor side of things, so I stuck with i3WM.
For this experiment, it was good enough.
Then I discovered reims-vgpu
After spending all that time experimenting with Docker-OSX, I eventually came across reims-vgpu.
It takes a different approach to running macOS virtual machines. It's an experimental virtual GPU for QEMU that uses the host's Vulkan driver, along with a custom QEMU build and a management utility called reims-ctl.
The project handles much of the VM management that I had previously been configuring manually. More importantly, its virtual GPU implementation addresses one of the biggest limitations I had run into with Docker-OSX: graphics acceleration.
I installed it and gave it a try. The difference was quite noticeable. Graphics acceleration was working, audio was working, and resolution handling was considerably better. The overall desktop experience was much closer to what I had originally wanted.
After spending so much time digging through QEMU arguments and trying different configurations, it was nice to have something that handled these parts without requiring me to work everything out myself.
There is one important difference, though: reims-vgpu isn't Dockerized. It runs QEMU directly and manages virtual machines through its own tooling. But that made me realise that I never really needed Docker itself. What I wanted was an isolated macOS environment that wouldn't interfere with my Arch installation, and a virtual machine already provides that.
Docker-OSX was simply the first solution I found that matched the way I wanted to work. reims-vgpu turned out to be a better fit for the actual problem.
It's worth mentioning that reims-vgpu is still experimental software. Compatibility depends on the host GPU, drivers, kernel, and other hardware-specific factors, so my experience shouldn't be treated as a universal guarantee.
The funny part
After all this, I realised I don't actually need macOS. I don't use it as my daily driver, I don't have any particular application that requires it, and I still don't particularly like the operating system. I just wanted to see if I could run it on my Linux machine.
The whole experiment started with Hackintosh, moved to virtualization when my hardware wasn't suitable, and eventually turned into an exercise in understanding Docker and QEMU. I built a macOS disk image, got Docker-OSX running, experimented with virtual hardware, and wrote a startup script to make the whole thing easier to manage.
Then I found a project that handled most of the things I had been trying to fix.
I don't think every experiment needs to turn into a long-term project. Sometimes you get curious about something, spend a few evenings making it work, learn a bunch of things along the way, and eventually move on. This was one of those experiments, and I'm happy with what I got out of it.
I learned quite a bit about Docker internals, QEMU, KVM, OpenCore, virtual hardware, and display forwarding. More importantly, I got to understand how all these pieces fit together rather than treating the setup as a black box.
Moving on
I'll probably keep reims-vgpu around for whenever I feel like booting macOS again. Docker-OSX was a useful starting point, even though I couldn't get everything working the way I wanted. I wouldn't call the project officially abandoned, but it wasn't quite giving me the experience I was looking for anymore.
I still use Arch Linux, and I still prefer my minimal i3WM setup. I have no particular interest in switching to macOS, but at least now I know I can run it whenever I want.
I wanted macOS on Linux. Hackintosh didn't work. Docker-OSX got me halfway there. reims-vgpu took me the rest of the way. And then I realised I didn't even need macOS in the first place.
That's Linux for you.
What's next?
I've also been thinking about giving Omarchy a shot. I've been using my own minimal Arch + i3WM setup for quite some time, so trying something more opinionated and preconfigured could be interesting. Maybe that'll turn into a comparison between Omarchy and my current setup, or perhaps I'll finally write a guide on building your own Linux distro.
Yes, I'm talking about HeimOS. I've had that project sitting around for a while, and I really should get back to it. Maybe experimenting with Omarchy will give me the motivation to finally finish what I started.
But that's a story for another blog.
This is an experimental account of my own setup. The commands and configurations are preserved from my notes and may need adjustments depending on your hardware and Docker-OSX version.