https://github.com/dockur/macos
macOS inside a Docker container.
https://github.com/dockur/macos
docker docker-container mac macos macos-virtual-machine macos-vm macosx osx osx-virtual-machine virtualization
Last synced: 2 days ago
JSON representation
macOS inside a Docker container.
- Host: GitHub
- URL: https://github.com/dockur/macos
- Owner: dockur
- License: mit
- Created: 2024-06-02T19:42:37.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-04-08T05:58:55.000Z (7 days ago)
- Last Synced: 2025-04-13T00:36:48.563Z (2 days ago)
- Topics: docker, docker-container, mac, macos, macos-virtual-machine, macos-vm, macosx, osx, osx-virtual-machine, virtualization
- Language: Shell
- Homepage:
- Size: 1.3 MB
- Stars: 11,483
- Watchers: 38
- Forks: 434
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
- awesome-ccamel - dockur/macos - macOS inside a Docker container. (Shell)
- awesome-starred - dockur/macos - macOS inside a Docker container. (Shell)
- stars - macos
- stars - macos
README
OSX
[![Build]][build_url]
[![Version]][tag_url]
[![Size]][tag_url]
[![Package]][pkg_url]
[![Pulls]][hub_url]OSX (macOS) inside a Docker container.
## Features β¨
- KVM acceleration
- Web-based viewer
- Automatic download## Usage π³
##### Via Docker Compose:
```yaml
services:
macos:
image: dockurr/macos
container_name: macos
environment:
VERSION: "13"
devices:
- /dev/kvm
- /dev/net/tun
cap_add:
- NET_ADMIN
ports:
- 8006:8006
- 5900:5900/tcp
- 5900:5900/udp
volumes:
- ./macos:/storage
restart: always
stop_grace_period: 2m
```##### Via Docker CLI:
```bash
docker run -it --rm --name macos -p 8006:8006 --device=/dev/kvm --device=/dev/net/tun --cap-add NET_ADMIN -v ${PWD:-.}/macos:/storage --stop-timeout 120 dockurr/macos
```##### Via Kubernetes:
```shell
kubectl apply -f https://raw.githubusercontent.com/dockur/macos/refs/heads/master/kubernetes.yml
```##### Via Github Codespaces:
[](https://codespaces.new/dockur/macos)
## FAQ π¬
### How do I use it?
Very simple! These are the steps:
- Start the container and connect to [port 8006](http://127.0.0.1:8006/) using your web browser.- Choose `Disk Utility` and then select the largest `Apple Inc. VirtIO Block Media` disk.
- Click the `Erase` button to format the disk to APFS, and give it any name you like.
- Close the current window and proceed the installation by clicking `Reinstall macOS`.
- When prompted where you want to install it, select the disk you created previously.
- After all files are copied, select your region, language, and account settings.
Enjoy your brand new machine, and don't forget to star this repo!### How do I select the version of macOS?
By default, macOS 13 (Ventura) will be installed, but you can add the `VERSION` environment variable in order to specify an alternative:
```yaml
environment:
VERSION: "13"
```Select from the values below:
| **Value** | **Version** | **Name** |
|-------------|----------------|------------------|
| `15` | macOS 15 | Sequoia |
| `14` | macOS 14 | Sonoma |
| `13` | macOS 13 | Ventura |
| `12` | macOS 12 | Monterey |
| `11` | macOS 11 | Big Sur |> [!NOTE]
> Support for macOS 15 (Sequoia) is still in its infancy, as it does not allow you to sign in to your Apple Account yet.### How do I change the storage location?
To change the storage location, include the following bind mount in your compose file:
```yaml
volumes:
- ./macos:/storage
```Replace the example path `./macos` with the desired storage folder or named volume.
### How do I change the size of the disk?
To expand the default size of 64 GB, add the `DISK_SIZE` setting to your compose file and set it to your preferred capacity:
```yaml
environment:
DISK_SIZE: "256G"
```
> [!TIP]
> This can also be used to resize the existing disk to a larger capacity without any data loss.### How do I change the amount of CPU or RAM?
By default, the container will be allowed to use a maximum of 2 CPU cores and 4 GB of RAM.
If you want to adjust this, you can specify the desired amount using the following environment variables:
```yaml
environment:
RAM_SIZE: "8G"
CPU_CORES: "4"
```### How do I assign an individual IP address to the container?
By default, the container uses bridge networking, which shares the IP address with the host.
If you want to assign an individual IP address to the container, you can create a macvlan network as follows:
```bash
docker network create -d macvlan \
--subnet=192.168.0.0/24 \
--gateway=192.168.0.1 \
--ip-range=192.168.0.100/28 \
-o parent=eth0 vlan
```
Be sure to modify these values to match your local subnet.Once you have created the network, change your compose file to look as follows:
```yaml
services:
macos:
container_name: macos
....
networks:
vlan:
ipv4_address: 192.168.0.100networks:
vlan:
external: true
```
An added benefit of this approach is that you won't have to perform any port mapping anymore, since all ports will be exposed by default.> [!IMPORTANT]
> This IP address won't be accessible from the Docker host due to the design of macvlan, which doesn't permit communication between the two. If this is a concern, you need to create a [second macvlan](https://blog.oddbit.com/post/2018-03-12-using-docker-macvlan-networks/#host-access) as a workaround.### How can macOS acquire an IP address from my router?
After configuring the container for [macvlan](#how-do-i-assign-an-individual-ip-address-to-the-container), it is possible for macOS to become part of your home network by requesting an IP from your router, just like your other devices.
To enable this mode, in which the container and macOS will have separate IP addresses, add the following lines to your compose file:
```yaml
environment:
DHCP: "Y"
devices:
- /dev/vhost-net
device_cgroup_rules:
- 'c *:* rwm'
```### How do I pass-through a disk?
It is possible to pass-through disk devices or partitions directly by adding them to your compose file in this way:
```yaml
devices:
- /dev/sdb:/disk1
- /dev/sdc1:/disk2
```Use `/disk1` if you want it to become your main drive, and use `/disk2` and higher to add them as secondary drives.
### How do I pass-through a USB device?To pass-through a USB device, first lookup its vendor and product id via the `lsusb` command, then add them to your compose file like this:
```yaml
environment:
ARGUMENTS: "-device usb-host,vendorid=0x1234,productid=0x1234"
devices:
- /dev/bus/usb
```### How do I share files with the host?
To share files with the host, add the following volume to your compose file:
```yaml
volumes:
- ./example:/shared
```Then start macOS and execute the following command:
```shell
sudo -S mount_9p shared
```In Finderβs menu bar, click on βGo β Computerβ to access this shared folder, it will show the contents of `./example`.
### How do I verify if my system supports KVM?First check if your software is compatible using this chart:
| **Product** | **Linux** | **Win11** | **Win10** | **macOS** |
|---|---|---|---|---|
| Docker CLI | β | β | β | β |
| Docker Desktop | β | β | β | β |
| Podman CLI | β | β | β | β |
| Podman Desktop | β | β | β | β |After that you can run the following commands in Linux to check your system:
```bash
sudo apt install cpu-checker
sudo kvm-ok
```If you receive an error from `kvm-ok` indicating that KVM cannot be used, please check whether:
- the virtualization extensions (`Intel VT-x` or `AMD SVM`) are enabled in your BIOS.
- you enabled "nested virtualization" if you are running the container inside a virtual machine.
- you are not using a cloud provider, as most of them do not allow nested virtualization for their VPS's.
If you did not receive any error from `kvm-ok` but the container still complains about a missing KVM device, it could help to add `privileged: true` to your compose file (or `sudo` to your `docker` command) to rule out any permission issue.
### How do I run Windows in a container?
You can use [dockur/windows](https://github.com/dockur/windows) for that. It shares many of the same features, and even has completely automatic installation.
### How do I run a Linux desktop in a container?
You can use [qemus/qemu](https://github.com/qemus/qemu) in that case.
### Is this project legal?
Yes, this project contains only open-source code and does not distribute any copyrighted material. Neither does it try to circumvent any copyright protection measures. So under all applicable laws, this project will be considered legal.
However, by installing Apple's macOS, you must accept their end-user license agreement, which does not permit installation on non-official hardware. So only run this container on hardware sold by Apple, as any other use will be a violation of their terms and conditions.
## Acknowledgements π
Special thanks to [seitenca](https://github.com/seitenca), this project would not exist without her invaluable work.
## Stars π
[](https://starchart.cc/dockur/macos)## Disclaimer βοΈ
*Only run this container on Apple hardware, any other use is not permitted by their EULA. The product names, logos, brands, and other trademarks referred to within this project are the property of their respective trademark holders. This project is not affiliated, sponsored, or endorsed by Apple Inc.*
[build_url]: https://github.com/dockur/macos/
[hub_url]: https://hub.docker.com/r/dockurr/macos/
[tag_url]: https://hub.docker.com/r/dockurr/macos/tags
[pkg_url]: https://github.com/dockur/macos/pkgs/container/macos[Build]: https://github.com/dockur/macos/actions/workflows/build.yml/badge.svg
[Size]: https://img.shields.io/docker/image-size/dockurr/macos/latest?color=066da5&label=size
[Pulls]: https://img.shields.io/docker/pulls/dockurr/macos.svg?style=flat&label=pulls&logo=docker
[Version]: https://img.shields.io/docker/v/dockurr/macos/latest?arch=amd64&sort=semver&color=066da5
[Package]: https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fipitio.github.io%2Fbackage%2Fdockur%2Fmacos%2Fmacos.json&query=%24.downloads&logo=github&style=flat&color=066da5&label=pulls