DEV Community

Running macOS inside Linux with Docker-OSX

Gergely Gombos on January 16, 2022

Originally appeared on my blog. It just happened to me that at my current workplace, Process Street, I had to fix a bug in our iOS application. Bu...
Collapse
 
jailsonpaca profile image
jailsonpaca

to be abble to coonect to Apple Id we need also to put -e GENERATE_UNIQUE=true in the command

Collapse
 
liviufromendtest profile image
Liviu Lupei

This is interesting, but how many hours did it take you?
There are services like MacStadium, that provide access to real MacOS machines for a small price.
From your company's perspective, would it have been less costly just to use MacStadium for a few days instead of instaling MacOS on a Linux machine?
Taking into consideration your hourly rate multiplied by the number of hours dedicated to this task.

Collapse
 
gombosg profile image
Gergely Gombos • Edited

Good question! Setting up the container itself didn't take much time, at most half a workday. Setting up the whole environment took something like a day in total, but that was because it takes time to set up any dev environment. Even if I had a MacBook or a MacStadium access, it would have taken a few hours to get to the first successful compile, just like if I was onboarding at the company.

(Think Git access, HTTPS certs with mkcert, installing a different Xcode version, getting Ruby work with rbenv, messing with build parameters and environment variables a bit.)

And now I have access to a ready-to-use Xcode environment 1 click away, for free. It really amazed me how smooth the experience was. And this is a long-term investment because it may very well happen that in the upcoming months I'll have to code some feature in that environment.

Collapse
 
gerzonc profile image
gerzonc

wow this definitely seems like something that might work for me personally. I've wanted to buy a System76 laptop for myself in a long time already but being unable to run my apps for iOS was keeping me from doing it

Collapse
 
gombosg profile image
Gergely Gombos

Well, don't expect wonders though because it's only a fairly slow VNC connection. But maybe there are some workarounds or different ways to connect to QEMU to make it feasible for daily production use.

Collapse
 
plutohddev profile image
PlutoHD

Thank you for this great article! I'm currently trying to install Docker-OSX on my NAS without a desktop environment on it, so I decided to go for the VNC version. However, when I try to build the image (docker build -t docker-osx:nakedvnc -f Dockerfile.nakedvnc .), the build ends with the following error: toptal.com/developers/hastebin/uji...
I would really appreciate any advice!

Collapse
 
094459 profile image
Ricardo Sueiras

As someone who has previous run hackintosh, this is super interesting. I am defo going to try this out - thanks for putting this together.

Collapse
 
meligy profile image
Meligy

Hello,
I heard a lot that it's not legal to run macOS on a non-Apple machine. Do you know anything about this?

Thanks

Collapse
 
gombosg profile image
Gergely Gombos

Docker-OSX links to this article explaining the situation. tl;dr it's legal as long as you use it in good faith for security research, and report security bugs to Apple. IANAL.

Collapse
 
mpashka profile image
Pavel Moukhataev

As far as I know you are not able to sign in into apple using your apple id if you are not using genuine apple device. So you are not able to sign you iOS apps and publish them via xcode. Or not?

Thread Thread
 
gombosg profile image
Gergely Gombos

I haven't published via own keys. But I was able to sign in via Apple ID just fine. The VM appears as a Mac Pro.

Collapse
 
vbao profile image
csvobao

can I ask how the performance look like compare to some product? Just wondering because I haven't used any Apple product before

Collapse
 
raibtoffoletto profile image
Raí B. Toffoletto

There's also github.com/kholia/OSX-KVM

Last time I needed a VM it was super easy... But I didn't figure out how to run it from virt-manager.

Collapse
 
gombosg profile image
Gergely Gombos

Definitely, I have also found this project! I guess that this Docker solution is just a bit more turnkey and reproducible as it ships its own QEMU inside the container, and solely relies on a KVM kernel module.

Collapse
 
ichavezf profile image
Eduardo Chavez

I have a question. Its posible compile apps into that image? Flutter o Swift?

Collapse
 
gombosg profile image
Gergely Gombos

Yes, you can use any kind of software inside the image including compilation. It' quite fast thanks to KVM.

Collapse
 
duard profile image
Carlos Eduardo

there is no sound from HDMI of my GTX 1050ti :-( and only 1920x1080

Collapse
 
gombosg profile image
Gergely Gombos

See the Docker-OSX readme. I haven't tried sound as I don't need it, but you can change resolution with a single docker run parameter.

Collapse
 
javitolin profile image
Javi • Edited

This sounds amazing.
Thanks for sharing.

Collapse
 
billious profile image
Bill Raty

This is fantastic, and adds helpful process flow to the firehose of sickcodes' README.

Collapse
 
duard profile image
Carlos Eduardo

What about resolution and VGA ? Im using GTX 1050ti with 4k resolution