Skip to main content

Docker performance can be slower on Windows and macOS compared to Linux for a few reasons:

  1. Docker uses different virtualization technologies: Docker relies on containerization technology to create lightweight, portable, and isolated environments for running applications. On Linux, Docker uses the host OS's kernel directly for containerization, which provides near-native performance. However, on Windows and macOS, Docker uses different virtualization technologies to achieve containerization, such as Hyper-V (on Windows) and xhyve (on macOS), which introduce an additional layer of virtualization and may impact performance. 

  2. File system performance: Docker on Windows and macOS relies on translating file system calls between the host OS and the containers, which can introduce performance overhead compared to the direct file system access used by Docker on Linux. This can impact I/O-intensive workloads, such as those that involve frequent reading and writing of large files. So when it comes to running code quality checks like phpcs, or linting in containers, I have seen it take upto 20 minutes while running it in containers and a few seconds in Linux. 

  3. Resource allocation: Docker containers on Windows and macOS may require more resources, such as CPU, memory, and disk space, compared to Linux due to the overhead of virtualization technologies used. This can result in slower performance if the host machine does not have sufficient resources to allocate to the Docker containers.

  4. Docker Desktop: Docker Desktop, which is the official Docker application for Windows and macOS, provides a user-friendly GUI for managing Docker containers, but it also adds additional overhead compared to using Docker directly on Linux. Docker Desktop includes additional components, such as the Docker daemon, networking components, and other services, which can consume system resources and affect performance. Docker desktop is now available in Ubuntu and it is more of a curse than a blessing. Many devs have started using it on Ubuntu and it causes a lot of issues and the dev become lazy and are woefully ignorant of docker cli capabilities.

  5. Configuration and settings: Docker on Windows and macOS may require additional configuration and settings to optimize performance, such as adjusting resource limits, using different storage drivers, or configuring networking options. If these settings are not optimized for your specific use case, it can impact Docker performance. In my experience, it doesn't help one bit on Mac and if you are using windows for developing on docker, I applaud your courage.

In my many years of experience using all sorts of Mac devices and various other devices, the Mac is not just slow, it is stupidly slow! As in how can you develop anything quickly, if you are waiting for cache to clear half the time. Evidence:

  1. docker pull abhaisasidharan/bench:latest
  2. time docker run -it abhaisasidharan/bench:latest python3 bench.py
  3. time docker run -it abhaisasidharan/bench:latest python3 bench.py silent
  4. docker pull abhaisasidharan/drupal-bench:latest
  5. docker run -itd --name=drupalbench abhaisasidharan/drupal-bench
  6. time docker exec -it  drupalbench drush si --db-url=mysql://root:bitnami_drupal1234@localhost:3306/drupal -y
  7. time docker exec -it  drupalbench drush si demo_umami --db-url=mysql://root:bitnami_drupal1234@localhost:3306/drupal -y

Run the above in Linux and Mac and see for yourself. I did these a couple of years ago to prove to my friend that the new Mac M(1/2)s are more of the same and nothing new for Developers who use virtualization. The context for these are very different and I'm not saying Mac devices are bad for everything. When using virtualization, with file read/writes and database read/writes, your going to have a tough time with Mac devices. We ran many tests with the above commands along with timing some day to day tasks and realized that the performance on Linux laptops were almost 2 or 3 times better. Not that's a huge margin!

The main reason for this hude margin is because Docker uses something called namespaces to provide OS Level virtualization. DOCKER CANNOT RUN WITHOUT THE LINUX KERNEL. If you have used Linux and looked at the htop or top or system monitor outputs, you might have come across some of these namespaces. See here. In short, Docker runs on Linux, creates a separation of these namespaces which behaves like a new OS altogether. Which is also why you are so efficiently able to control performance and memory in docker containers on Linux.

Tags

x

Work

Therefore logo
80 Atlantic Ave, Toronto, ON Canada
Email: hello@therefore.ca
Call us: +1 4166405376
Linkedin

Let us know how we can help!