DEV Community

Cover image for Why is Docker on macOS So Much Worse Than Linux?

Why is Docker on macOS So Much Worse Than Linux?

Eric Nograles on August 02, 2020

We've all heard the jokes from practically anyone with their development environments on Docker for Mac: it makes your Mac sound like a jet plane a...
Collapse
 
pinceladasdaweb profile image
Pedro Rogério
Collapse
 
barbosaeli profile image
Eli Barbosa • Edited

I used to work with Docker for MacOS (with NFS volume) and indeed it's much faster than use the default volume map but even NFS volume is very, very slow compare to Docker on Linux, it's unbelievable.

Collapse
 
ericnograles profile image
Eric Nograles

Good links, Pedro. We'd looked into this as well, but it seemed docker-sync was a smidge faster and slightly more reliable. NFS looked solid overall though!

Collapse
 
corentinbettiol profile image
Corentin Bettiol

We use nfs to setup our devenv across all of our developers computers (linux/macos), it works fine :)

Collapse
 
rrrix profile image
Rick Bowen

@ericnograles read this!!

docs.docker.com/docker-for-mac/osx...

Basically adding the "delegated" flag to docker volumes will help AMAZINGLY with CPU and I/O performance. Don't just trust me on it, try it!

Collapse
 
ericnograles profile image
Eric Nograles

Thanks for the link! SUPER interesting -- although if I'm reading that article above properly, it sounds like it'd be more of a cached (i.e. host is the authority) setup?

How has your experience been day-to-day? i.e. do the container volumes ever get out of sync, and if they do, is there a quick mechanism to get them back to parity (without having to straight up docker-compose down && docker-compose up -d?

Collapse
 
timsayshey profile image
Tim Badolato

Inspired by Windows WSL which runs a Linux VM that is integrated with Windows. I decided to setup a Linux VM on Mac and install my Docker dev environment on the Linux VM. It actually runs a lot better than my native Mac Docker environment. I'm using Parallels Desktop which is a lot more performant than Virtual Box so that could also help things as well. I haven't seen or heard of anyone else doing this but it was the only way for me to get my dev environment to run from my Mac without running out of resources.

Collapse
 
ericnograles profile image
Eric Nograles

Right there with you! I actually use a VirtualBox VM and just hook my host tooling up to it via SSH. Works so much better than Docker for Mac!

Collapse
 
timsayshey profile image
Tim Badolato

Awesome! You should write a post about :)

Collapse
 
barbosaeli profile image
Eli Barbosa • Edited

I used to work with Docker on MacOS for almost two years but some weeks ago I just gave up. After a comparison that I did running Docker on Linux, the MacOS version (Including the use of NFS volumes) is too slow.

If you can get rid of MacOS and use Linux, go ahead, I'm pretty sure, you won't regret.

Collapse
 
ecourtial profile image
Eric COURTIAL

This article is very interesting. I knew that Docker for Mac OS was different and running inside a VM, but not with such details.
However IMHO there is a little bit of exageration: it is working correctly on my machine, and the overhead in comparison with the Linux setup is not such a pain.

Collapse
 
ericnograles profile image
Eric Nograles • Edited

Thanks for sharing, Eric.

I think it's a case of YMMV here. We have a pretty I/O heavy setup with our front-end (i.e. webpack) and, without mitigation, it constantly chews through resources. Checking my Activity Monitor right now, at idle, my docker.hyperkit on my MBP sits at 40%...and that's with help from docker-sync.

Without mitigation, it's not unusual for it to sit at 90%+, especially when you're saving source code a bunch from the host.

Collapse
 
moopet profile image
Ben Sinclair

On my work MBP with large projects it's up to about 50 times slower than on Linux running IO heavy apps, particularly those which have to monitor for changes or recursively search directories.

Collapse
 
shimtrevor profile image
Trevor Shim

Great article! Built a solution to this problem that runs your local containers on remote linux machines: getporter.dev - I would love your honest thoughts on how this compares to your experience with Mutagen.

Collapse
 
victoredier profile image
Victor Edier

I had less issues running docker inside an Ubuntu VM than directly in Mac 😟

Collapse
 
cuvtixo profile image
Chris Daniels

This makes some sense, unfortunately. If indeed the case generally, Docker devs should suggest such a solution, rather than providing a substandard VM of their own for MacOS. I'm hearing these reports after learning of "Doki malware" and I'm losing confidence in the product. Or should I say I'm losing faith in the organization behind the product.

Collapse
 
ericnograles profile image
Eric Nograles • Edited

Part of me agrees with you. However, they (Docker) are definitely in a tough spot. Whereas Microsoft was cooperative in creating a bridge to their kernel with WSL-2, Apple generally keeps macOS under lock and key. i.e. Docker for Mac will be at the mercy of the macOS Hyperkit.

The fact that the new Docker for Mac will ship with Mutagen def shows me that they hear us and are doing whatever they can to alleviate the situation.

Collapse
 
ericnograles profile image
Eric Nograles

fwiw, I've taken the Docker Edge Build with Mutagen for a spin and it's been very good! Once they work out the kinks, hopefully it consistently improves the experience for everyone.

Collapse
 
omrisama profile image
Omri Gabay

The heating and cooling issues you're talking about will hopefully go away anyway when Macs switch to ARM

Collapse
 
nkululekodube profile image
Nkululeko Dube

Is it not better to just install vm on your Mac, spin up a Linux OS and then install docker on that?

Collapse
 
ericnograles profile image
Eric Nograles

Better performing, definitely.

However, it does come with the additional tax of more networking overhead in the form of port forwards to/from the host/guest, or reverse proxying for more complicated setups.

Collapse
 
jimpriest profile image
Jim Priest

I keep revisiting these posts every few months. Looks like Mutagen integration isn't happening now so I think I'll try the Linux VM as well.

Collapse
 
espoir profile image
Espoir Murhabazi

Eric, thanks for the docker edge tip!.....

I had this issue for a month and at some point, I thought about taking my mac to a repair shop but this really helps me .....

Keep it up...

Collapse
 
ohbadiah profile image
Nicholas McAvoy

Idunno man, some people on my team at work just use Ubuntu, and I hear it works great for them!

Great explanation though, thanks.

Collapse
 
ericnograles profile image
Eric Nograles

Oh, you. 😆

Collapse
 
teja463 profile image
Brahma Teja Ponnuru

Wouldn't the same happens when you try to run a windows based docker image on a Linux Machine?

Collapse
 
lukwe profile image
Luca Post.

a new Docker 3.6 had been released recently…. is Mutagen included in there ?
or maybe the Mac OS sluggishness had been treated in same other way (?!)

Collapse
 
alvinhu profile image
Alvin Hu

It's end of 2021. The docker for mac is updated at 4.2.0. Is these problems still there?

Collapse
 
codepau profile image
Pau&company

Hi!
Do you know where can I found information about Mac's performance when running a Linux Docker image vs running a Linux VM without having to run them myself? I am sure someone has measured it!