diff --git a/Dockerfile b/Dockerfile index 01d2887..f57989a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,7 +58,6 @@ SHELL ["/bin/bash", "-c"] # change disk size here or add during build, e.g. --build-arg VERSION=10.14.5 --build-arg SIZE=50G ARG SIZE=200G -ARG VERSION=10.15.6 # OPTIONAL: Arch Linux server mirrors for super fast builds # set RANKMIRRORS to any value other that nothing, e.g. -e RANKMIRRORS=true @@ -139,32 +138,16 @@ RUN touch enable-ssh.sh \ # RUN yes | sudo pacman -Syu qemu libvirt dnsmasq virt-manager bridge-utils edk2-ovmf netctl libvirt-dbus --overwrite --noconfirm -RUN yes | sudo pacman -Syu qemu libvirt dnsmasq virt-manager bridge-utils openresolv jack ebtables edk2-ovmf netctl libvirt-dbus wget --overwrite --noconfirm \ +RUN yes | sudo pacman -Syu bc qemu libvirt dnsmasq virt-manager bridge-utils openresolv jack ebtables edk2-ovmf netctl libvirt-dbus wget --overwrite --noconfirm \ && yes | sudo pacman -Scc WORKDIR /home/arch/OSX-KVM -RUN wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/fetch-macOS.py +# RUN wget https://raw.githubusercontent.com/kholia/OSX-KVM/master/fetch-macOS-v2.py -RUN [[ "${VERSION%%.*}" -lt 11 ]] && { python fetch-macOS.py --version "${VERSION}" \ - && qemu-img convert BaseSystem.dmg -O qcow2 -p -c BaseSystem.img \ - && qemu-img create -f qcow2 mac_hdd_ng.img "${SIZE}" \ - && rm -f BaseSystem.dmg \ - ; } || true +ARG SHORTNAME -# VERSION=11.2.1 -# this downloads LATEST ONLY -ARG FETCH_MAC_OS_RAW=https://raw.githubusercontent.com/acidanthera/OpenCorePkg/master/Utilities/macrecovery/macrecovery.py -# submit a PR to here to get the version option https://github.com/acidanthera/OpenCorePkg/blob/master/Utilities/macrecovery/macrecovery.py - -RUN [[ "${VERSION%%.*}" -ge 11 ]] && { wget "${FETCH_MAC_OS_RAW}" \ - && python macrecovery.py download \ - && qemu-img convert BaseSystem.dmg -O qcow2 -p -c BaseSystem.img \ - && qemu-img create -f qcow2 mac_hdd_ng.img "${SIZE}" \ - && rm -f BaseSystem.dmg \ - ; } || true - -WORKDIR /home/arch/OSX-KVM +RUN make ARG LINUX=true @@ -202,7 +185,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< '-drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=${BOOTDISK:-/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2} \' \ && tee -a Launch.sh <<< '-device ide-hd,bus=sata.2,drive=OpenCoreBoot \' \ && tee -a Launch.sh <<< '-device ide-hd,bus=sata.3,drive=InstallMedia \' \ - && tee -a Launch.sh <<< '-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2 \' \ + && tee -a Launch.sh <<< '-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=raw \' \ && tee -a Launch.sh <<< '-drive id=MacHDD,if=none,file=${IMAGE_PATH:-/home/arch/OSX-KVM/mac_hdd_ng.img},format=${IMAGE_FORMAT:-qcow2} \' \ && tee -a Launch.sh <<< '-device ide-hd,bus=sata.4,drive=MacHDD \' \ && tee -a Launch.sh <<< '-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900,${ADDITIONAL_PORTS} \' \ diff --git a/README.md b/README.md index 3703444..36639b8 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,13 @@ Run Mac OS X in Docker with near-native performance! X11 Forwarding! iMessage se The Discord is active on #docker-osx and anyone is welcome to come and ask questions, ideas, etc.
-### Click to join the Discord server [https://discord.gg/mx8pPw39Yg](https://discord.gg/mx8pPw39Yg) +### Click to join the Discord server [https://discord.gg/sickchat](https://discord.gg/sickchat) ### Click to join the Telegram server [https://t.me/sickcodeschat](https://t.me/sickcodeschat) @@ -50,7 +50,7 @@ Video setup tutorial is also available here: https://www.youtube.com/watch?v=wLe First time here? try [initial setup](#initial-setup), otherwise try the instructions below to use either Catalina or Big Sur. ## Any questions, ideas, or just want to hang out? -# [https://discord.gg/mx8pPw39Yg](https://discord.gg/mx8pPw39Yg) +# [https://discord.gg/sickchat](https://discord.gg/sickchat) ### Catalina [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest](https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) @@ -74,7 +74,7 @@ docker run -it \ -e "DISPLAY=${DISPLAY:-:0.0}" \ sickcodes/docker-osx:big-sur -# docker build -t docker-osx --build-arg VERSION='Big Sur' . +# docker build -t docker-osx --build-arg SHORTNAME=big-sur . ``` ### Monterey [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/monterey?label=sickcodes%2Fdocker-osx%3Amonterey](https://img.shields.io/docker/image-size/sickcodes/docker-osx/monterey?label=sickcodes%2Fdocker-osx%3Amonterey)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) @@ -90,7 +90,7 @@ docker run -it \ -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \ sickcodes/docker-osx:monterey -# docker build -t docker-osx -f Dockerfile.monterey . +# docker build -t docker-osx --build-arg SHORTNAME=monterey . ``` #### Run Catalina Pre-Installed [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) @@ -112,6 +112,38 @@ docker run -it \ # passsword is alpine ``` +### Older Systems + +### High Sierra [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/high-sierra?label=sickcodes%2Fdocker-osx%3Ahigh-sierra](https://img.shields.io/docker/image-size/sickcodes/docker-osx/high-sierra?label=sickcodes%2Fdocker-osx%3Ahigh-sierra)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +```bash + +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 + +# docker build -t docker-osx --build-arg SHORTNAME=high-sierra . +``` + +### Mojave [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/mojave?label=sickcodes%2Fdocker-osx%3Amojave](https://img.shields.io/docker/image-size/sickcodes/docker-osx/mojave?label=sickcodes%2Fdocker-osx%3Amojave)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +```bash + +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 + +# docker build -t docker-osx --build-arg SHORTNAME=mojave . +``` + + + #### Download the image manually and use it in Docker [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) @@ -255,31 +287,44 @@ SEE commands in [https://github.com/sickcodes/osx-optimizer](https://github.com/ ## Important notices: -**2021-09-09** - Bootdisks at runtime required for Monterey! +**2021-11-14** - Added High Sierra, Mojave -Pick one of these: +Pick one of these while **building**, irrelevant when using docker pull: ``` - -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \ - - -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-nopicker-custom.plist' \ +--build-arg SHORTNAME=high-sierra +--build-arg SHORTNAME=mojave +--build-arg SHORTNAME=catalina +--build-arg SHORTNAME=big-sur +--build-arg SHORTNAME=monterey ``` ## Technical details -There currently five images, each with different use cases (explained [below](#container-images)): +There currently multiple images, each with different use cases (explained [below](#container-images)): +- High Sierra +- Mojave - Catalina - Big Sur +- Monterey - Auto (pre-made Catalina) - Naked (use your own .img) - Naked-Auto (user your own .img and SSH in) -Catalina make your own image: +High Sierra: + +[![https://img.shields.io/docker/image-size/sickcodes/docker-osx/high-sierra?label=sickcodes%2Fdocker-osx%3Ahigh-sierra](https://img.shields.io/docker/image-size/sickcodes/docker-osx/high-sierra?label=sickcodes%2Fdocker-osx%3Ahigh-sierra)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +Mojave: + +[![https://img.shields.io/docker/image-size/sickcodes/docker-osx/mojave?label=sickcodes%2Fdocker-osx%3Amojave](https://img.shields.io/docker/image-size/sickcodes/docker-osx/mojave?label=sickcodes%2Fdocker-osx%3Amojave)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) + +Catalina: [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest](https://img.shields.io/docker/image-size/sickcodes/docker-osx/latest?label=sickcodes%2Fdocker-osx%3Alatest)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) -Big-Sur make your own image: +Big-Sur: [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/big-sur?label=sickcodes%2Fdocker-osx%3Abig-sur](https://img.shields.io/docker/image-size/sickcodes/docker-osx/big-sur?label=sickcodes%2Fdocker-osx%3Abig-sur)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) @@ -287,25 +332,26 @@ Monterey make your own image: [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/monterey?label=sickcodes%2Fdocker-osx%3Amonterey](https://img.shields.io/docker/image-size/sickcodes/docker-osx/monterey?label=sickcodes%2Fdocker-osx%3Amonterey)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) -Pre-made system by [Sick.Codes](https://sick.codes): username: `user`, password: `alpine` +Pre-made **Catalina** system by [Sick.Codes](https://sick.codes): username: `user`, password: `alpine` [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/auto?label=sickcodes%2Fdocker-osx%3Aauto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) -Bring-your-own-image setup (use any of the above first): +Naked: Bring-your-own-image setup (use any of the above first): [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked?label=sickcodes%2Fdocker-osx%3Anaked)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) -Same as above but with `-e USERNAME` & `-e PASSWORD` and `-e OSX_COMMANDS="put your commands here"` +Naked Auto: same as above but with `-e USERNAME` & `-e PASSWORD` and `-e OSX_COMMANDS="put your commands here"` [![https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked-auto?label=sickcodes%2Fdocker-osx%3Anaked-auto](https://img.shields.io/docker/image-size/sickcodes/docker-osx/naked-auto?label=sickcodes%2Fdocker-osx%3Anaked-auto)](https://hub.docker.com/r/sickcodes/docker-osx/tags?page=1&ordering=last_updated) ## Capabilities -- use iPhone OSX KVM on Linux using usbfluxd! -- macOS Monterey! -- Folder sharing +- use iPhone OSX KVM on Linux using [usbfluxd](https://github.com/corellium/usbfluxd)! +- macOS Monterey VM on Linux! +- Folder sharing- +- USB passthrough (hotplug too) - SSH enabled (`localhost:50922`) - VNC enabled (`localhost:8888`) if using ./vnc version -- [serial number generator!](https://github.com/sickcodes/osx-serial-generator) +- iMessage security research via [serial number generator!](https://github.com/sickcodes/osx-serial-generator) - X11 forwarding is enabled - runs on top of QEMU + KVM - supports Big Sur, custom images, Xvfb headless mode @@ -313,9 +359,9 @@ Same as above but with `-e USERNAME` & `-e PASSWORD` and `-e OSX_COMMANDS="put y ### Requirements -- 20GB disk space for bare minimum installation +- 20GB+++ disk space for bare minimum installation (50GB if using Xcode) - virtualization should be enabled in your BIOS settings -- a kvm-capable host +- a x86_64 kvm-capable host - at least 50 GBs for `:auto` (half for the base image, half for your runtime image ### TODO @@ -399,6 +445,9 @@ Create your personal image using `:latest` or `big-sur`. Then, pull the image ou - `sickcodes/docker-osx:big-sur` - [I want to run Big Sur.](#quick-start-docker-osx) - `sickcodes/docker-osx:monterey` - [I want to run Monterey.](#quick-start-docker-osx) +- `sickcodes/docker-osx:high-sierra` - I want to run High Sierra. +- `sickcodes/docker-osx:mojave` - I want to run Mojave. + ## Initial setup Before you do anything else, you will need to turn on hardware virtualization in your BIOS. Precisely how will depend on your particular machine (and BIOS), but it should be straightforward. @@ -428,7 +477,7 @@ sudo modprobe kvm ## Additional boot instructions for when you are [creating your container](#container-creation-examples) -- Boot the macOS Base System +- Boot the macOS Base System (Press Enter) - Click `Disk Utility` @@ -439,6 +488,8 @@ sudo modprobe kvm - Click `Reinstall macOS` +- The system may require multiple reboots during installation + ## Troubleshooting ### Routine checks @@ -489,7 +540,9 @@ This will use all available cores; adjust accordingly to the day of the week: This will use `-smp $(nproc)` -#### Confirm your user is part of the the Docker group, KVM group, libvirt group +### Confirm your user is part of the the Docker group, KVM group, libvirt group + +#### Add yourself to the Docker group If you use `sudo dockerd` or dockerd is controlled by systemd/systemctl, then you must be in the Docker group. If you are not in the Docker group: @@ -509,17 +562,17 @@ See also: [initial setup](#initial-setup). #### Is the docker daemon enabled? ```bash +# run ad hoc +sudo dockerd + +# or daemonize it +sudo nohup dockerd & + # enable it in systemd (it will persist across reboots this way) sudo systemctl enable --now docker # or just start it as your user with systemd instead of enabling it systemctl start docker - -# or run ad hoc -sudo dockerd - -# or daemonize it -sudo nohup dockerd & ``` ## More Questions and Answers @@ -883,7 +936,7 @@ docker build -t docker-osx:latest \ --build-arg RANKMIRRORS=true \ --build-arg MIRROR_COUNTRY=US \ --build-arg MIRROR_COUNT=10 \ - --build-arg VERSION=10.15.6 \ + --build-arg SHORTNAME=catalina \ --build-arg SIZE=200G . ``` diff --git a/tests/big-sur_master.png b/tests/big-sur_master.png new file mode 100644 index 0000000..b3e0636 Binary files /dev/null and b/tests/big-sur_master.png differ diff --git a/tests/boot-images.sh b/tests/boot-images.sh new file mode 100644 index 0000000..6b914b9 --- /dev/null +++ b/tests/boot-images.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# Author: Sick.Codes https://twitter.com/sickcodes +# Contact: https://github.com/sickcodes, https://sick.codes +# Copyright: sickcodes (C) 2021 +# License: GPLv3+ +# Title: Docker-OSX (Mac on Docker) +# Repository: https://github.com/sickcodes/Docker-OSX +# Website: https://sick.codes +# +# Status: Used internally to run each image and take screenshots until they match the pngs in this folder. +# + +# note to self: # to get master images, boot each image, then screen shot using DISPLAY=:99 in the test.sh script +# scrot -o high-sierra_master.png +# scrot -o mojave_master.png +# scrot -o catalina_master.png +# scrot -o big-sur_master.png +# scrot -o monterey_master.png +# pull off remote server to the tests folder +# REMOTE_SERVER= +# scp root@"${REMOTE_SERVER}":~/*_master.png . + +export DISPLAY=:99 + +TESTS=( + high-sierra + mojave + catalina + big-sur + monterey +) + +# test each docker image to see if they boot to their unique respective installation screens. + +for TEST in "${TESTS[@]}"; do + # run the image detached + docker run --rm -d \ + --device /dev/kvm \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=:99" \ + "sickcodes/docker-osx:${TEST}" + + # imcat the expected test screenshot to ./"${TEST}_master.txt" + imcat ~/Docker-OSX/tests/${TEST}_master.png > ./"${TEST}_master.txt" + + # run until the screen matches the expected screen + while :; do + sleep 5 + # screenshot the Xvfb + scrotcat > ./"${TEST}.txt" + # diff the low res txt files created from imcat + diff "./${TEST}.txt" ./"${TEST}_master.txt" && break + scrotcat + done + + # kill any containers + docker kill "$(docker ps --format "{{.ID}}")" + + # ensure all containers are dead + until [[ "$(docker ps | wc -l)" = 1 ]]; do + sleep 1 + docker ps | xargs docker kill + done + +done + +exit 0 diff --git a/tests/catalina_master.png b/tests/catalina_master.png new file mode 100644 index 0000000..9749507 Binary files /dev/null and b/tests/catalina_master.png differ diff --git a/tests/high-sierra_master.png b/tests/high-sierra_master.png new file mode 100644 index 0000000..9a5a8c7 Binary files /dev/null and b/tests/high-sierra_master.png differ diff --git a/tests/mojave_master.png b/tests/mojave_master.png new file mode 100644 index 0000000..4a9c8b6 Binary files /dev/null and b/tests/mojave_master.png differ diff --git a/tests/monterey_master.png b/tests/monterey_master.png new file mode 100644 index 0000000..15c33b6 Binary files /dev/null and b/tests/monterey_master.png differ diff --git a/tests/test.sh b/tests/test.sh index e66f04f..84ec774 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,4 +1,4 @@ -#!/usr/bin/docker +#!/usr/bin/bash # ____ __ ____ ______ __ # / __ \____ _____/ /_____ _____/ __ \/ ___/ |/ / # / / / / __ \/ ___/ //_/ _ \/ ___/ / / /\__ \| / @@ -12,7 +12,7 @@ # Repository: https://github.com/sickcodes/Docker-OSX # Website: https://sick.codes # -# Status: Work in progress. +# Status: Used internally to auto build, run and test images on DO. # help_text="Usage: ./test.sh --branch