108
votes

Can Mac OS X be run inside Docker? If so, any suggestion as to how?

And would it be running headless, or there would be a possibility to connect to the GUI remotely?

1

3 Answers 3

59
votes

Docker provides methods for managing OS-level containers and is built on top of Linux's native features for OS-level containerization. All containers running on a system share the same kernel; Mac OS X does not use the Linux kernel, but rather a mach kernel, so it cannot be run inside a Docker container at this time.

You can run Docker on your Mac using a virtual machine, but containers running on that instance would need to run Linux.

Now that Docker uses libcontainer rather than LXC as its basis, it is possible that porting of libcontainer in the future could one day allow for running Windows and Mac OS Docker containers on those systems respectively, but it would depend on appropriate OS features being available to allow for containerization.

4
  • 18
    so [Mac] cannot be run inside a Docker container at this time. <-- Are there any updates on this now? Or are we still restricted to pure Linux applications?
    – Hippo
    Aug 9, 2016 at 4:24
  • 8
    Nowadays (Jan 2017) docker runs on windows platform and is able to run either windows or linux kernel-based images, but not both at the same time
    – MaxXx1313
    Feb 2, 2017 at 15:57
  • 8
    The question is about runnning MacOS inside a virtual environment. The questions was not whether a MacOS can run Docker.
    – Ken Ingram
    Dec 29, 2018 at 17:09
  • No need for a VM on macOS to run Docker.
    – Jonny
    May 1, 2020 at 5:06
31
votes

Running an OSX VM in a Docker container is possible. Take a look at https://github.com/Cleafy/sxkdvm for example.

4
  • 17
    Running a VM inside a Container seems to be kind of missing the point of containers...
    – Shayne
    Jan 9, 2019 at 6:35
  • 2
    Agreed. This is an impressive achievement, but there's near zero advantage to doing so. May 7, 2019 at 18:51
  • Well what if you want to build an electron app for osx?
    – Krimson
    Jul 17, 2019 at 0:09
  • 4
    If you want to orchestrate an OSX machine using the many available tools for docker, this makes sense. For example for CI purposes. Aug 1, 2019 at 12:07
6
votes

If you want to run macOS directly inside Docker, the answer is no, see @phoebus's answer.

If you really need it it, see @Andrea Brancaleon's answer which suggests to install macOS inside VM inside Docker.

But if you're wondering if the solution above is possible according to macOS' licence, than the answer is again no*.

Quoting software license agreement for macOS Catalina, section 2, point B:

[...] you are granted a limited, non-transferable, non-exclusive license: [...]
(iii) to install, use and run up to two (2) additional copies or instances of the Apple Software
within virtual operating system environments on each Mac Computer you own or control that is
already running the Apple Software, for purposes of: (a) software development; (b) testing during
software development; (c) using macOS Server; or (d) personal, non-commercial use.

It's same for older macOS versions.


* unless you're going to run macOS inside a virtual machine inside a Linux Docker container inside a Linux virtual machine on macOS host system on Mac hardware

Not the answer you're looking for? Browse other questions tagged .