Self-hosting macOS virtual machines has become an area of interest for developers, QA teams, and IT professionals seeking a contained testing environment. The dockurr/macos project provides a streamlined method to run macOS within Docker using QEMU and KVM acceleration. This article explains the setup process, key requirements, and important compliance considerations.
Apple’s licensing terms only permit macOS to be virtualised on Apple-branded hardware. Running a macOS guest on non-Apple devices constitutes a licence breach. Organisations intending to deploy this workflow must ensure hosts are Apple hardware to remain compliant with Apple’s End User Licence Agreement (EULA).
The container relies on hardware virtualisation and networking support. Before deploying, verify:
- CPU virtualisation: Intel VT-x or AMD-V enabled in BIOS/firmware.
- KVM device: /dev/kvm must exist and be accessible to Docker. On Linux, install qemu-kvm, libvirt packages, and test with kvm-ok.
- TUN device: /dev/net/tun must be present. Load with modprobe tun if missing.
- Nested virtualisation: If running inside another VM, ensure nested KVM is enabled.
These prerequisites enable QEMU to provide near-native CPU performance.
A standard docker-compose.yml file provisions the macOS guest. An example:
1services:
2 macos:
3 image: dockurr/macos
4 container_name: macos
5 environment:
6 VERSION: "15" # macOS Sequoia
7 RAM_SIZE: "20G"
8 CPU_CORES: "8"
9 DISK_SIZE: "128G"
10 devices:
11 - /dev/kvm
12 - /dev/net/tun
13 cap_add:
14 - NET_ADMIN
15 ports:
16 - "8006:8006" # Web console
17 - "5900:5900/tcp" # VNC
18 - "5900:5900/udp"
19 volumes:
20 - ./macos:/storage
21 restart: always
22 stop_grace_period: 2m
Persistent storage, including the VM disk, is maintained in the ./macos directory. Resource allocation can be customised for RAM, CPU, and disk size.
Once deployed, the installation proceeds through Apple’s recovery utilities:
Run docker compose up -d to launch the service.
Access via browser at http://localhost:8006 or through a VNC client on port 5900.
In Disk Utility, erase the largest "VirtIO Block Media" disk and format as APFS.
Choose "Reinstall macOS" and complete the guided setup. The installer will download files and reboot several times.
The installation can take considerable time depending on network throughput.
- Acceleration: KVM enables hardware-accelerated virtualisation, delivering improved responsiveness.
- Interface: Native VNC clients provide smoother display performance compared with the web console.
- Persistence: VM state is stored on the mapped volume, ensuring continuity across restarts.
- Networking: Assigning NET_ADMIN and /dev/net/tun supports bridged networking for internet connectivity.
These optimisations enhance usability but performance will still be below bare-metal macOS.
Common issues include:
- Download: Adjust DNS entries in the Compose file (e.g., 1.1.1.1, 8.8.8.8).
- Permission: Ensure the Docker user is in the kvm group.
- Devices: Load required kernel modules (kvm, tun).
Following the GitHub project’s issue tracker provides current solutions to version-specific problems.
The dockurr/macos image delivers a practical framework for running macOS virtual machines within Docker. When executed on Apple hardware, it provides a compliant, cost-effective option for testing, training, and software validation. With proper configuration, teams can achieve reliable macOS virtualisation backed by KVM performance and persistent containerised management.