This is a quick guide to get macOS running in Docker on Ubuntu Desktop!
Full credits go to Sick.Codes, and all the other contributers that can be listed here and here.
kholia for maintaining OSX-KVM.
thenickdude for maintaining KVM-OpenCore, which was started by Leoyzen.
The OpenCore team (https://github.com/acidanthera/OpenCorePkg).
If you like this project, consider contributing here!
This guide is a combination of information gathered and modified from the BlueBubbles Wiki and Docker-OSX README.md. Full credits go to them 😊
This guide uses a fresh install of Ubuntu Desktop 22.04 LTS (download), updated with
sudo apt update
sudo apt upgrade
Prerequisite Setup (source)
- Turn on hardware virtualisation in your BIOS
- Install QEMU and other dependancies with:
sudo apt install qemu qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager libguestfs-tools make gcc git screen
- Clone this repo for a copy of the bash scripts (or you can just copy and paste them into your terminal)
git clone https://github.com/vandamd/Docker-OSX.git
- Install Docker (source)
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
- Enable Docker usage as a non-root user (source)
sudo groupadd docker
sudo usermod -aG docker $USER
- Log out and log back in
newgrp docker
- (On a different machine,) download a VNC Viewer such as TigerVNC or VNC Viewer. This is used for remotely accessing macOS inside the Docker container
Initiating the base image (source)
- Run the first bash script to initiate the base image:
bash Docker-OSX/1_baseimage.sh
- Connect to macOS via VNC, your VNC Server address may look like
192.168.1.77:5999
. Your IP Address is probably something else, can find it usinghostname -I
Install macOS (source)
-
Boot into macOS Base System (Press Enter)
-
Click
Disk Utility
-
Erase the BIGGEST disk (around 200gb default), DO NOT MODIFY THE SMALLER DISKS. If you can't click
erase
, you may need to reduce the disk size by 1kb -
Click
Reinstall macOS
. The system may require multiple reboots during installation -
Setup macOS as normal. You can sign into iCloud during setup or do it later, it doesn't matter
-
Once finished, DO NOT OPEN iMessage
-
Shutdown macOS as normal
Extract image (source)
- Run the second bash script:
bash Docker-OSX/2_extractimage.sh
This script finds mac_hdd_ng.img
from /var/lib/docker
, then copies it to the home folder.
NOTE: This may take a while!
Generate Unique Serial (source)
- Run the third bash script:
bash Docker-OSX/3_genserial.sh
This generates credentials such as SMBIOS, Serial Number, UUID so that the VM looks like an actual Mac! These credentials are placed in the home folder.
You can verify if your serial number is suitable by entering into Apple's Check Coverage site. You should get the message 'Unable to check coverage for this serial number.' in red font. If not, run delete the file called my_permanent_serial_number.sh
in your home folder and run the third bash script again.
First Run (source)
- Run the fourth bash script:
bash Docker-OSX/4_firstrun.sh
-
Connect via VNC using the same address as before
-
Login to macOS as usual, open iMessage and setup iCloud Sync
-
Setup AirMessage/BlueBubbles!
Subsequent Runs (source)
- From now on you only need to run the fifth bash script to turn on the Docker container
bash Docker-OSX/5_subrun.sh
If you want macOS to turn on when you boot up Ubuntu, you can change the restart policy. You can find out here. I used Portainer to do it as I prefer managing other containers with it!
If it's a bit slow you can look at this to optimise macOS.
For those of you who are running on a Dell XPS like I am, consider limiting your battery charge with Dell's Command | Configure, and disabling suspension when closing the lid.
- You can find Dell's Command | Configure here, search for your laptop model
sudo ./cctk --PrimaryBattChargeCfg=Custom:50-80
- To disable suspension when lid is closed, install Gnome Tweak Tool, open it and disable suspension