Install macOS Big Sur or Catalina in a virtual machine using Docker-OSX

Docker-OSX It is a project that enables OSX-KVM in a Docker container to make macOS run near the machine. Using this feature, you will be able to install macOS in a QEMU virtual machine (via Docker) and run the macOS Catalina or Big Sur desktop, or boot into the OSX Shell.

The Docker-OSX project provides four Docker images:

  • sickcodes/docker-osx:latest -Use macOS Catalina’s original base recovery image
  • sickcodes/docker-osx:big-sur -Use the original base recovery image of macOS Big Sur
  • sickcodes/docker-osx:naked -Provide your own .img file (use -v "${PWD}/disk.img:/image")
  • sickcodes/docker-osx:auto -A large (~19.4GB) docker image to boot into OSX Shell (SSH is enabled, use user as username and alpine as password; you need about 50GB of disk space to run this image)

Features include:

  • X11 forwarding
  • Fully automatic mode: Directly boot to OSX Shell, and even run commands as runtime parameters
  • Kubernetes rudder diagram.Look . /rudder
  • SSH on localhost:50922
  • VNC version is turned on localhost:8888 (This VNC version Since the use of VNC involves security risks, it is located in a separate directory)
  • Use docker commit to create an ARMY of the exact same container
  • Xfvb headless mode

The project also includes instructions for various adjustments, such as forwarding other ports, changing the screen resolution, enabling network forwarding, allowing USB pass-through, quick start instructions for using large pre-made images and using your own image, etc. (All content is available in Project page).

It is worth noting from the beginning that Apple does not allow macOS to be installed on non-Apple hardware, so to use this feature legally, your OS must be installed on Apple hardware. In addition, to use this function, your computer’s CPU needs to support hardware virtualization.View KVM list from here To determine if your CPU supports it (if everything is ok, you can also run sudo kvm-ok, it will return “KVM acceleration available”).

On my Ubuntu 20.10 desktop, use sickcodes/docker-osx:big-sur The image took about 55 minutes. The Docker image occupies about 3.2 GB of disk space, and the container space usage is about 35 GB.

You may also want to check out Sosumi, which is a snapshot package that can easily download and install macOS Catalina in a virtual machine on Linux, which also uses QEMU + KVM and is based on macOS-Simple-KVM. It is worth noting that Sosumi has not been updated since its first release.

Below, you will find information about using Docker (Docker-OSX) to run macOS (Catalina or Big Sur) basic recovery image, install and run macOS (with the option to set a custom resolution; if no option is specified, use 1920×1080) Description. . There are also instructions for removing the container.

You might also like: LazyDocker: Docker and Docker Compose Terminal UI

How to install macOS (OSX) in QEMU + KVM using Docker-OSX

1. Prerequisites.

Before proceeding, please make sure that your computer supports hardware virtualization and that it is enabled in the BIOS (you can check if you are using sudo kvm-ok If everything is normal, it will return “KVM acceleration is available”). Once you have done this, you can continue with the rest of the instructions below.

First make sure you have Docker installed (See also official Docker installation documentation).

also Install QEMU On the host system (if not already installed).You may also need to add the user to the kvm group using the following command sudo usermod -aG kvm $USER To make it work properly.

As for the required disk space, please read my comments from the rest of this article for a rough estimate.in order to sickcodes/docker-osx:auto You will need about 50 GB of disk space to use it.

2. Start Docker-OSX.

Use Docker-OSX to run macOS Big Sur or Catalina (see the Docker-OSX project page for other options-for example, you can run it Headless, use your own image, Run sick code/docker-osx: latest allows SSH to enter macOS, ETC. ; You may also want to see these Custom QEMU parameters Can be used to set the number of CPU cores, available RAM, etc.):

  • Run macOS Big Sur (change WIDTH with HEIGHT The value of the screen resolution you want to use for the macOS Big Sur virtual machine; I use the following 1600×900), using the basic recovery image:
docker run -it     --device /dev/kvm     -p 50922:10022     -e GENERATE_UNIQUE=true     -e DEVICE_MODEL="iMacPro1,1"     -e WIDTH=1600     -e HEIGHT=900     -v /tmp/.X11-unix:/tmp/.X11-unix     -e "DISPLAY=${DISPLAY:-:0.0}"     sickcodes/docker-osx:big-sur
  • Run macOS Catalina (change WIDTH with HEIGHT The value of the screen resolution you want to use for the macOS Big Sur virtual machine; I use the following 1600×900), using the basic recovery image:
docker run -it     --device /dev/kvm     -p 50922:10022     -e GENERATE_UNIQUE=true     -e DEVICE_MODEL="iMacPro1,1"     -e WIDTH=1600     -e HEIGHT=900     -v /tmp/.X11-unix:/tmp/.X11-unix     -e "DISPLAY=${DISPLAY:-:0.0}"     sickcodes/docker-osx:latest

This may take a few minutes.

The above Docker run command uses the basic option to start macOS (basic recovery image, used to install macOS) in the QEMU using Docker provided on the Docker-OSX project page, and adds the screen resolution option.If you delete GENERATE_UNIQUE, DEVICE_MODEL, WIDTH with HEIGHT Option, the virtual machine will use the default (1920×1080) screen resolution.

3. Use Disk Utility to format the largest QEMU HARDDISK.

After a few minutes, the macOS virtual machine will start.Boot to the macOS base system and select Disk Utility From the menu:

macOS QEMU Docker Disk Utility

Next, in the Disk Utility tool, check which of the 2 QEMU HARDDISK media is the largest hard disk on the left, and then click the largest hard disk (214.75 GB in the version I used to test this version).

Tip: To let the QEMU virtual machine release the mouse, press Ctrl + Alt + g (In some cases, this is just Ctrl + g).

Click now Erase Click the “button” on the “Disk Utility” toolbar to format the hard disk:

macOS QEMU Docker Disk Utility

Set a name for the disk, such as “macOS”, and leave the other options as default (they are Format: APFS for macOS Big Sur and Mac OS Extended (Journaled) for macOS Catalina, GUID for both modes Zoning map).

After erasing the largest QEMU HDD, close the Disk Utility dialog box.

4. Install macOS in the virtual machine.

After closing “Disk Utility”, you will enter the menu again, from which you can start “Disk Utility” and so on. However, this time, you need to choose the following options: Reinstall macOS Big Sur (Or if you are using sickcodes/docker-osx:latest With pictures of Catalina, this option is called Reinstall macOS):

macOS QEMU Docker reinstall

Click on ContinueAnd then Agree, You will enter a screen where you can select the HDD formatted in step 3 (the HDD is displayed with the name you entered when erasing, for example macOS In our example).Select the hard drive and click Continue:

macOS QEMU Docker select disk

macOS Big Sur / Catalina (depending on the image you selected) will now start to install:

macOS QEMU Docker installation

After a while, the mac OSX virtual machine will restart.select macOS Installer Enter at boot:

macOS QEMU Docker installer

After the installation is complete, this boot entry will change to “macOS” and allow you to boot into the new macOS installation inside the virtual machine:

macOS QEMU Docker macOS start menu

Now, you need to choose your country or region, you can choose to log in with your Apple ID, agree to terms and conditions, etc., and create your computer account (user name and password).

Please note that after installing macOS for the first time and launching it, I had to select the macOS entry twice (restarted after the first choice). In addition, there will be mouse lag (and general lag) during macOS installation, but once you run the installed macOS virtual machine, this will not happen again (or become less obvious; it depends on your computer hardware) ).

5. Start the newly installed macOS virtual machine.

When you want to start the newly installed macOS virtual machine, run docker ps -a View container ID and/or name:

docker ps -a

Then start the container:

docker start Container_ID_or_Name

instead Container_ID_or_Name And the container ID or name obtained using the previous command.

You might also like: Portainer: Web-based Docker GUI for remote or local use

How to delete Docker-OSX

Therefore, you have decided to delete Docker-OSX. First run the following command to get a list of Docker container names and IDs:

docker container ls -a

Use this command to determine which container to delete. Now, stop and use the following method to remove the container:

docker container stop ID_or_Image

docker container rm ID_or_Image

instead ID_or_Image And the container ID or image obtained using the previous command.

To delete a Docker-OSX image, first use the following command to list the existing Docker images:

docker image ls

Next, delete the Docker-OSX image using the following command:

docker image rm Image_ID

instead Image_ID Use the image ID obtained from the previous command.

by cerebrux.net (GR)

Source

Related Posts