Docker on new MacBook Pro with M1 Pro chip in 2022?
What changed in 2022?
Running Docker on Apple MacBook computers has been a common problem for many developers since the beginning. In many cases, it performs so badly that we are forced to look for different, alternative solutions. Probably there are also people who decided to replace their MacBooks with Linux based computers. In my previous article I made a comprehensive approach to finding the best option for those, who do not want to replace their Apple computers with anything else but still are forced to use Docker.
In this article I am going to consider different volume configurations (default, cached, delegated) for Docker on Mac, using Docker on VPS, and mutagen (as a solution for files synchronization with Docker). My final decision for 2021 was to use external VPS, although the approach with mutagen seemed promising.
I changed a few things since that time, I changed my VPS, and what is most important, I changed my MacBook Pro to a new model.
Wondering how it impacted Docker performance? Bear with me. But first, let’s have a look at changes in my setup.
|CPU||4 cores||2 cores|
|Model||MacBook Pro 14” (2021)||MacBook Pro 13” |
(2017 without touch bar)
|CPU||M1 Pro - 10 cores||Intel Core i5 - 2 cores|
Is it worth buying a new MacBook Pro with Apple Silicon?
There is no doubt that the MacBook with the new Apple M1 Pro chip with ARM architecture is a very powerful machine. You can feel the difference right away, in any aspect. It is fast, quiet and it is not getting too warm even on a high load. I’m very glad that I changed my old one to this model.
But in the case of Docker, there is no simple answer to that question.
What about Docker?
There is no better way to find an answer to that question than some benchmarking.
I used the same methodology as in my previous article. Also, tests were performed on the same project with the same data.
Docker for Mac has some settings which might influence general performance. It is related to resource allocations. For example, you can allocate 4 CPUs and 8GB of RAM or you can increase that number according to what you need. I used the settings visible below.
Building Docker images
Let’s start with something that should not be influenced too much by volume performance - Docker builds.
As you can see, the difference is huge. Docker image was built in only seven minutes on MacBook M1 Pro, which was even better than the build time on my new VPS. This is not surprising, I gave Docker quite a lot of resources. But it also shows that if there are not too many I/O disk operations, performance is quite good. What is also important, my computer did not slow down during that process. I was able to use it normally and it did not even reach 60 degrees Celsius.
Based on that you can think that there is hope that finally Docker can work fast on MacBook, but keep reading.
Let’s check how fast Docker containers will handle requests on Apple Silicon
This time I did not play too much with volume configuration, I checked only cached and delegated. Besides that, I set up mutagen, because it was very promising last time.
Volume setting has not too much impact on performance. It performs slightly better in comparison to my old MacBook but it is still slow for both cached and delegated. What is interesting here is how fast it is with mutagen. Looks like if we take out I/O disk operations out of the equation we will finally have a setup which can perform very well, maybe even better than on Linux.
Is Docker desktop with Mutagen still slower than running Docker on VPS?
VPS was the ultimate winner of my previous tests. It has many advantages and it was the fastest one. Running Docker with Mutagen directly on a MacBook was an alternative solution which I rated very well. It was still a little bit slower, and what is most important - very resource consuming, but it had a chance to compete with Linux based servers. Because I have a new VPS, with a similar number of CPU cores and a similar amount of RAM that I allocated in Docker on Mac, let’s find out if it can beat M1 Pro.
Results are quite ok, it is faster than my previous VPS, but surprisingly it is significantly slower than Docker on MacBook Pro with Apple M1 Pro chip and mutagen.
Final thoughts on Docker MacBook Pro M1
To be honest when I was buying a new MacBook I was not thinking about running Docker on it. I assumed that my setup on VPS is good enough and I can still use it. And probably I wouldn't check its performance if I didn't want to write this article.
After all these tests and checks I am really surprised. I did not expect that it could be so fast. Still, VPS has some advantages (it can be used on multiple devices, it can be used for other purposes etc.) but it is slower and needs a constant internet connection.
So my decision for 2022 is: Docker on Mac M1 Pro with Mutagen
More info on how to configure and use Mutagen with Docker can be found in my previous article.
I don’t know how Docker on Mac with mutagen will perform in the long term, but I do not expect any problems as I’m using mutagen on a daily basis to sync files with VPS. So I will definitely give it a shot.
There is another aspect worth considering, money.
New Apple computers are quite expensive, when I’m writing this (February 2022) you need to spend 1999$ on the cheapest version of MacBook Pro 14”. My VPS costs 4.99$ per month, so the cost of a new MacBook is equivalent to around 33 years of using VPS.
Taking that into consideration I would advise you to first check how fast is Docker with mutagen on your current MacBook and if it is not fast enough, but your Mac is still good and you are perfectly happy with it (besides Docker performance), use VPS, instead spending a lot of money on the new machine.
Are there any other options to consider?
Improving performance might be achieved also by optimizing the build process and container configuration. We have published a free ebook on that - Docker Deep Dive. Applying the techniques described in the ebook we optimized the build time from 17 to 5 minutes on the VPS, and to ~2 minutes on a bigger dedicated server that we use for our CI jobs. So if you struggle with build times, I strongly advise you to download the ebook and have a look at some potential changes first.
We plan to write a follow-up article describing the mentioned Dockerfile optimization as a case-study article. Subscribe to our newsletter to not miss this update.
Docker like a pro!GET FREE EBOOK