108

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?

simone
  • 1,281
  • 2
  • 10
  • 10
  • Possible duplicate of http://serverfault.com/questions/573378/how-can-i-run-a-full-os-in-a-docker-container-without-specifying-a-command?rq=1 – neutrinus Jun 24 '14 at 06:59

3 Answers3

59

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.

phoebus
  • 8,370
  • 1
  • 31
  • 29
  • 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 09 '16 at 04: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 02 '17 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 '18 at 17:09
  • No need for a VM on macOS to run Docker. – Jonny May 01 '20 at 05:06
31

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

6

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

cubuspl42
  • 161
  • 1
  • 5