14 ms·
Docker on MacOS is slow and how to fix it
- rcarmo 4y agoI stopped using Docker desktop and just forwarded my Docker CLI to a VM’s TCP port the instant I found how it exported my Mac file system wholesale to the Docker VM. Never looked back, and these days I just use sshfs or VSCode to develop remotely (which works everywhere).
- EdwardDiego 4y agoMy preferred fix: don't develop in Docker.
- sieabahlpark 4y agoHave fun managing osx and Linux dependencies then when you could just maintain one.
- notwokeno 4y agoWhen I used to use a mac I just put all my "Linux" (GNU really) dependencies in a prefix and that worked pretty well. Docker is kind of overkill for what people use it for IMO.
- deleted 4y ago[deleted]
- dhritzkiv 4y agoI used to be on the side of relying on native tools/libs, and managing them in a similar way to what you to describe, but it all became too much to handle, with dependencies across projects breaking with regularity. Maybe I wasn't doing it right, but switching to Docker to sequester my projects and their dependencies has saved me so much time and hassle, especially with the amount of repos I work on throughout the year. My biggest weakness today is that I still don't reach for Docker right away when starting work on a new project or when evaluating a new tool. Old habits…
- notwokeno 4y agoMy point was that you can do this without docker. On Linux you can use separate chroots for each project, on OSX you could probably do that too but since prebuilt tools for generating a darwin rootfs are rarer prefixes are easier.
- rablackburn 4y agoI knows it’s becoming a bit of a meme now that modern software development is just rediscovering approaches from the 70s… but it has really hit me recently how so many “indispensable” projects are just something that’s existed for decades re-written at a higher abstraction-level with a nicer UX. I wish I had more classic Unix sysadmin experience. But unfortunately the gains are real, and I can’t justify investing time into learning the older tech (let’s say, using chroot instead of docker), when the newer is so much faster to learn, and has (comparative to modern hardware) such small overhead (if you’re not on MacOS :P) I am excited about the rust-rewrite movement for shell though - precisely because it’s a chance to bring all the ux lessons we’ve learned in the last decades to cli-tools. Stuff like charm.sh is super exciting.
- princevegeta89 4y agoAnd also there is some additional fun dealing with broken or incompatible packages whenever you upgrade OSX
- pjmlp 4y agoIndeed, one can maintain only a macOS application.
- nicoburns 4y agoIn the languages I work with (primarily JavaScript and Rust), cross-platform compatibility tends to be pretty much a non-issue. I develop on macOS, deploy on Linux, and it Just Works. No extra work required.
- sieabahlpark 4y ago[dead]
- nsonha 4y agoYou forget to mention all backend services (db, redis etc are managed and you need internet connection and cloud credentials for even a development workflow.
- nicoburns 4y agoI certainly do not use backend services that need to be hosted (if I can at all help it, which I usually can). Open source databases like Postgres and Redis are easy to install on macOS with homebrew. You can even have multiple versions install simultaneously, although I've found that Postgres tends to be backwards compatible enough that I just run everything on the latest version.
- acdha 4y agoThat really hasn’t been an issue for me since Homebrew came out a decade ago - using Python, Rust, Node, Java, etc., all of which have mature stories for cross-platform development. The main area I’ve run into problems are legacy projects where it’s not “Linux” but more like “one old Linux distribution with a 32-but binary nobody can reproduce” and Docker is really the least troublesome part of those projects.
- Spivak 4y agoIf you're not IT, god speed y'all, then it's not all that bad honestly. I set up my stuff with Ansible and 90% of the "porting" work was the mapping between rpms and brew packages. The only headache I get sometimes is because I have the GNU utils first in the path which makes compilation scripts mad sometimes.
- sieabahlpark 4y ago[dead]
- thunky 4y agoMy preferred fix: don't develop in Mac.
- princevegeta89 4y agoUnfortunately Mac is the best in terms of hardware and portability and for compliance stuff
- jrib 4y agoyeah, I really wanted to buy a Linux laptop. I highly value battery life though and the m1 chip doesn't really have a competitor in that department.
- devmunchies 4y ago> the m1 chip doesn't really have a competitor in that department the m2 chip :)
- vforvendettador 4y agoFor many Mac is the only sensible option. There's one developer in our company that uses Linux and it's a lot of pain to setup. Mac has the best balance between coding, utility tools and "other work stuff". Windows probably on par if not more for "work stuff" but falls badly in the coding & tooling department. Linux is OK ish for coding and utility but falls behind for "other work stuff" and certainly a pain to just keep it updated. So in our company, everyone in the development & support team uses Mac (except this one guy who insisted in Linux), most in the sales & marketing team use Windows.
- zamalek 4y ago> everyone in the development & support team uses Mac (except this one guy who insisted in Linux), > certainly a pain to just keep it updated. > Linux and it's a lot of pain to setup. If you're not using Linux, how are you justifying these claims? > certainly a pain to just keep it updated. Excluding the boot time for both, MacOS takes between 15 and 45min to update. Linux is a few seconds. I suspect that the only OS that has a more ridiculous update process than MacOS is Gentoo.
- RockRobotRock 4y agoThis is an unhelpful and useless comment
- mdavidn 4y agoAnd so is yours? I do often find myself wondering whether Docker saved developers or system administrators any time. Is Docker really better than building an AMI and provisioning EC2 instances on-demand?
- nsonha 4y agoYou provide multiple cloud environments for every dev?
- RockRobotRock 4y agoYes, I'm sure my wallet would be very happy with me running 20 different EC2 instances for small apps and databases.
- jeppester 4y agoAs a developer I can say that docker is saving me a lot of time that I would have otherwise spent on setting up different versions of postgres, redis, elastic search, etc. For the variety of client solutions we are building. With a docker compose file in place, all I need to do is run "docker-compose" and everything is up and running. It's such an upgrade over what we had before.
- hakanderyal 4y agoI finally gave up the effects of Docker on performance and battery life and switched to Windows. I still don't have a long lasting battery, but at least performance is better.
- rad_gruchalski 4y agoI have been working in a Citrix workspace Windows machine for the past 6 months with a Ubuntu 20 wsl2. I was very much anxious of the experience before onboarding but I have to say, I barely deal with the Windows side of things. Having said that, if I was to move away from mac, I‘d just go directly to Linux.
- hakanderyal 4y agoGaming is my guilty pleasure. While the gaming ecosystem on Linux is getting better everyday (thanks, Steam!), the limited time I spend on gaming doesn't allow me to tinker, I just want everything to run without limitations.
- therealmarv 4y agoIs not this the main way to speed up Docker on Mac: use a beefed up Linux Virtual Machine (VirtualBox, UTM, tart) and run Docker inside this Virtual Machine?
- dijit 4y agothe 'DOCKER_HOST' variable (and the fact that all SDK's seem to support it) is honestly the greatest bloody thing in the entire ecosystem. My workflow for the past 3 years with Docker has been: set up some desktop machine somewhere, configure docker, configure ssh like normal: set DOCKER_HOST=ssh://<tailscale_ip> on my laptop. Docker responds as if it's local, but I get absurd build/fetch speedup (since the wired connection is faster than Wifi) and it's not running inside a slow VM. Recently I've been using colima on my Mac natively, but I keep reaching for the DOCKER_HOST option.
- silverwind 4y agoI assume port forwarding would be a pain in such a setup, right?
- acchow 4y agoThis assumes you want a distinct storage drive within your VM. Many developers prefer to code in their host OS but run the image via Docker for Mac. They also want instant real-time code changes to appear inside the running Docker image. I suppose you could have some of the disk live within the VM and the code portions be memory mapped or Rsynced. I haven’t thought through the downsides.
- doctoboggan 4y agoWhat sort of workloads are people doing where the filesystem access is limiting them? I develop python web apps on a mac and use dockerized postgres and a dockerized flask app. I don't seem to experience any noticeable issues. When I am developing I mount the source code directory as a volume so code edits are synced live into the running docker container. I also develop frontends using vue, managed by npm. In my experience this doesnt need to be dockerized since npm installs everything in a subdirectory per project. Is there a benefit to running this as a dockerized app?
- xtracto 4y agoMagento in docker on Mac is horrible for this reason.
- deleted 4y ago[deleted]
- taf2 4y agonginx is pretty unusable via docker - I guess file system cache is the issue…
- osrec 4y agoYou can turn caching off, I believe.
- jeffrom 4y agoWorkloads with a lot of files, for example a large elixir web app with hot reload / fswatch enabled, have upwards of 20 second page load time. More than enough to mess up my flow.
- a_t48 4y agoI work on a _large_ C++ codebase on Linux. If I'm on my main (Linux) machine, things are fine, bind mounts are okay. If I'm stuck on my MacBook then compilation performance is...bad. I suspect it's due to heavy filesystem access from the compiler (reading source, writing object files, etc). At some point I need to confirm this by copying in my source directory.
- rootusrootus 4y agoFunny thing is that I switched from virtualbox for Vagrant on OSX over to Docker because vbox file operations were so incredibly slow.
- andix 4y agoOften overlooked: there is also podman machine and podman desktop (for windows and macOS). It is not as fancy as docker, but fully free and open source. It provides docker compatibility to some extent, you don’t need a license and it’s much less heavy than docker desktop. If you need kubernetes, there is also minikube, which provides a lot of options. Most of the things discussed in this article still apply for podman machine and minikube.
- laserlight 4y agoI've recently tried podman on a Mac and `podman machine start` failed with an “unknown error”. It was a disappointment.
- depereo 4y agoI had similar issues when podman desktop first came out. Working much better on a re-try this week.
- null0ranje 4y agoI want podman to be a drop-in replacement, but it just isn’t there. I’ve wasted more time running down random errors I podman, so much so that I’ve switched back. Maybe in another year or two…
- dangoor 4y agoThere's also Rancher Desktop. I don't know if it's less heavy, but it doesn't require a license and also includes k8s. https://rancherdesktop.io/ https://rancherdesktop.io/
- SirensOfTitan 4y agoThe most recent version of Colima supports both virtiofs and mac's native virtualization framework (macOS 12.5+). I get totally acceptable performance using it.
- jscheel 4y agoDocker is cripplingly slow on MacOS. I have a maxed out 16" mbp... starting rspec on our app takes 55-60 seconds. Compare that to my coworkers on Linux and Windows, who both see sub 10 second boots, and it's absolutely impossible to be ok with those numbers.
- kevinhq 4y agothis is very true. not to mention it's very slow on its networking... i've given up docker on macOS long ago. If I was to use docker, I'll switch to my debian laptop. way much much faster.
- tut-urut-utut 4y agoHappy to give up Docker, but still using MacOS as a daily driver?
- josephg 4y agoEasy. Just do whatever you're doing in docker natively in macos. Python, Nodejs, Ruby, Rust, Postgres, etc can all run as native macos processes. The big advantage (aside from performance) is that you gain access to all the OS-native debugging capacities. You can just look at files, open multiple terminal sessions in the same folder, use Profiler, click the debug button without special configuration in your IDE, and so on. All without needing to think about VM images, docker containers, networking and all that rubbish. The downside is you need to set up a second build environment (which might not match your deployment environment). Unless you're doing something truly special, setting up a macos-native build environment is usually pretty easy. Its normally just a few "brew install" / "npm" / "gem install" / "cargo build" etc commands away from working.
- ethbr0 4y agoSo because the macOS stack is janky, a solution is to ditch the standardization layer and run things directly in the janky stack? That seems like a road to bringing in an entire new set of environment-specific bugs and hacks.
- black_13 4y ago[dead]
- kevinhq 4y ago> We had to abandon Docker because we had folks with macOS on the team. But, other tasks (email, conference calling, scanning, word, upgrading without breakage) came with more friction, and those tend to fill up ever larger shares of my day. source: https://kvz.io/macos-install.html https://kvz.io/macos-install.html
- tropshop 4y agoI have Apple Silicon but develop on docker x86. The game changer for me was macOS Ventura with rosetta support for linux vms. I use UTM to run Debian 11 ARM. The update-binfmts command is absolutely magical, docker images will happily run both arm and x86 binaries. Battery lasts all day and the machine stays ice-cold. https://docs.getutm.app/advanced/rosetta/ https://docs.getutm.app/advanced/rosetta/
- KyeRussell 4y agoIt’s no surprise that these replies have seen the usual jarring unfriendly personalities come out of the woodwork to advocate for the absolute use of desktop Linux.
- TimTheTinker 4y agoMy preferred fix: pay for a Parallels Pro license and run Ubuntu on a VM, then run docker there. The VM is configured to start on login and run in the background. I have the Remote SSH plugin set up in VSCode, a `vmlogin` alias set up in bash, and all container ports forwarded in the VM's config.
- rubyist5eva 4y agoCan vouch for this approach, been using it for rails development for the past 6 months after my work swapped my macbook pro for an M1 Max Mac Studio and it's been solid.
- kdrag0n 4y agoFunny that this came up — shameless plug: I've actually been working on a new Linux+Docker+Kubernetes solution for macOS recently! Already added quite a few improvements over existing apps including Docker Desktop, Rancher, Colima, etc: - Fast networking: 30 Gbps! vs. 150 Mbps with Docker VPNKit. Full VPN compatibility, IPv6, ping, ICMP and UDP traceroute, and half-open TCP connections. - Bidirectional filesystem sharing: fast VirtioFS to access macOS from Linux, but also a mount to access the Linux filesystem from macOS. This setup can help with performance: for example, you could store code in Linux and edit it from macOS with VS Code (which can take the performance hit of sharing), so the container runs with native FS speed. - Not limited to Docker or Kubernetes. You can run multiple full Linux distros as system containers (like WSL) so they share resources. - Fast x86 emulation with Rosetta - Much lower background CPU usage. Only ~0.05% CPU usage and 2-5 idle wakeups per second — less than most apps, while Docker wakes up ~120 times per second. Made possible with low-level kernel optimizations. Also, no Electron! - Better solutions to other problems that can occur on macOS: clock drift is corrected monotonically, dynamic disk size, and more I'm working on now. Will look into memory usage too, although I can't guarantee a good fix for that. - No root needed. Planning to release this as a paid app in January. Not OSS, but I think the value proposition is pretty good and there will be a free trial. Not sure about pricing yet. If anyone is interested, drop me an email (see bio) and I'll let you know when this is ready for testing :) Also, feel free to ask questions here or let me know if there are other warts you'd like to see fixed.
- maccard 4y agoWhat are the tradeoffs?
- jitl 4y agoIt cost money sounds like the big one
- kdrag0n 4y agoThat's fair, but I think the value proposition is there for some :) I'm honestly not sure how pricing and licensing will work yet, but there will be some way to try it for free. Maybe something like Docker Desktop: free for personal use, license required for companies? That seems like a risky bet as an indie dev. There's also the whole question of one-time purchases vs. subscriptions. Subscriptions seem like the optimal model for this, so I'm not sure how to accommodate people who just don't like them. Would love to hear if you have any thoughts on how it could be done to reach as many users as possible.
- wood-porch 4y agoA project I made solved this by running docker on AWS and doing two-way file sync on changes. Runs quite nicely and transparently. https://github.com/lime-green/remote-docker-aws https://github.com/lime-green/remote-docker-aws Lots of benefits: speed, battery, fan noise
- pak9rabid 4y agoAnd money
- trillic 4y agoI use a shitbox of a thinkpad with my dev environment in the cloud, but they run Linux so I can just as easily run it locally if I have no connection. I buy them for $300-500 on eBay, upgrade them to at least 16gb of RAM and a 1TB Samsung SATA SSD. I have 2 cold spares ready to go, credentials loaded, just need to update and sync a few git repos. 14 inch 1080p IPS displays, i5 processor, 16GB of RAM. The money I save not paying for Apple laptops could pay for a crazy overpowered dev VM until the end of time. I used Apple laptops for about 10 years until about 5 keyboard replacements with the butterfly switch debacle.
- speedgoose 4y agoA MacBook is not that expensive and much faster than AWS VMs in the same price range (assuming a few years of usage) in my experience. The network storage of cloud VMs is particularly frustrating for development, unless you use ephemeral storage perhaps.
- xwowsersx 4y agoI have "use virtualization" turned on in Docker Desktop for Mac, but I don't see different options for the file sharing implementation. I'm currently on version 4.14.1 (91661). Separately, with "use virtualization" turned on, should I also enable "VirtioFS accelerated directory sharing"?
- ehutch79 4y agoIt’s under experimental features in 4.14. It’s the default where available in 4.15. You might need to upgrade both docker desktop and macOS.
- SanjayMehta 4y agoWe gave up on Docker on macOS long ago. Wherever we absolutely need Docker, we just throw a Linux machine at it. Developer time is costlier than hardware.
- mccolin 4y agoWith VirtioFS on the scene I just don’t have this experience anymore. Docker for Mac is significantly faster than it used to be, particularly when using named volumes. Mutagen also improved the experience but I prefer VirtioFS as it’s “built-in”
- westoque 4y agothis is one of the reasons i changed my OS to linux since docker there works natively. i believe there will always be a bottleneck for peak performance on macOS until we are able to run natively, not virtualized.
- aliljet 4y agoHave any of you tried to chase the microvm train instead of docker on MacOS? Thus far, it feels like this is a deeply lost cause with a passing hope that somehow you can hack a solution to nested virtualization and drop into a KVM-style experience on a guest vm and then go a layer deeper with microvms on top of that guest. Oofff. What an absolute horror show.
- benfrancom 4y agoI’m interested to see how project finch works out compared to Docker on a Mac. It’s an open source client for container development. https://github.com/runfinch https://github.com/runfinch When I tried Rancher Desktop it didn’t work so well.
- xenoscopic 4y agoIf anyone has any questions about Mutagen (or integrating it into their Docker-based workflows), I'm happy to help. Just one clarification on the article: Mutagen offers Docker Compose integration, not Composer integration (Composer is a PHP package manager). However, as mentioned, DDEV is a great option if you're looking to do containerized PHP development while using Mutagen for performance improvements.
- totalhack 4y agoI fixed this problem by not getting a MacBook Pro this year when my last one from 2018 had no battery and two letters falling off the keyboard. Bonus: paid half what a similarly spec'd M2 Air would cost.
- nsonha 4y agoWhy would you want to mount node_modules? it's useless on the host because the binaries are for a different arch
- ffactory 4y agoCool blog theme, feel like I've seen it before ;) https://filippo-orru.com/ https://filippo-orru.com/
- drcongo 4y agoI have a large, fairly complex Django application that I run in containers on a MBP with an M1 Pro, and it runs twice as fast as the AMD 16 core production server. It was a bit of a dog on an Intel Mac, but everything I use Docker for is blazing fast on Apple Silicon. Is there something about Python apps that makes this different?