Context
We all know that Docker performance on mac for some cases is quite limited in terms of filesystem performance, mainly caused by the shared network disk between the host and the docker for mac VM.
There is a long-standing issue you can find here: docker/roadmap#7
We as a company invested a lot in the past to reach close-native performance between Linux and macOS, in the docker-machine era we used NFS sharing which leads to very close native performance, then we decided to mainly use Linux for our developer workstations also to avoid this kind of performance issues.
With the Apple Silicon era, we decided to invest again in macOS for our developer workstations, as the machines are powerful, cheap and with the best-in-class hardware you can find on the market now.
The current Docker for Mac improved a lot the filesystem sharing issues, but it still falls behind the native performance, especially with heavy fs scenarios usage like Node and PHP with node_modules and vendor directories which can become very very big also in simple projects.
Benchmark
Repository: https://github.com/paolomainardi/docker-for-mac-bench
I am going to use create-react-app as a use case scenario, the test is executed:
- Empty
node_modules
- NPM cache
Filesystem
Native
❯ time npm install
real 6.12s
Doker for mac - gRPC Fuse (default)
❯ time npm install
real 56.835s
Docker for mac - Virtiofs (beta)
root@f546acf5bf5b:/usr/src/app# time npm install
real 18.864s
CPU
❯ make test-cpu
time node cpu-bench.js
4.08 real 4.01 user 0.06 sys
docker run --rm -it -v $PWD:/usr/src/app -v $PWD/.cache:/root/.npm -w /usr/src/app node:18-slim bash -c "time node cpu-bench.js"
real 0m4.138s
user 0m4.104s
sys 0m0.024s
macOS 13
❯ make test-native test-docker-nomount test-docker-nodemodule-mount test-docker-mount
Testing: Native installation...
real 4.66
Testing: Docker without volume mount...
real 0m 7.23s
Testing: Docker with node_modules mounted as a named volume...
real 0m 6.97s
Testing: Docker with volume mount...
real 0m 17.15s
Context
We all know that Docker performance on mac for some cases is quite limited in terms of filesystem performance, mainly caused by the shared network disk between the host and the docker for mac VM.
There is a long-standing issue you can find here: docker/roadmap#7
We as a company invested a lot in the past to reach close-native performance between Linux and macOS, in the docker-machine era we used NFS sharing which leads to very close native performance, then we decided to mainly use Linux for our developer workstations also to avoid this kind of performance issues.
With the Apple Silicon era, we decided to invest again in macOS for our developer workstations, as the machines are powerful, cheap and with the best-in-class hardware you can find on the market now.
The current Docker for Mac improved a lot the filesystem sharing issues, but it still falls behind the native performance, especially with heavy fs scenarios usage like
NodeandPHPwithnode_modulesandvendordirectories which can become very very big also in simple projects.Benchmark
Repository: https://github.com/paolomainardi/docker-for-mac-bench
I am going to use
create-react-appas a use case scenario, the test is executed:node_modulesFilesystem
Native
Doker for mac - gRPC Fuse (default)
Docker for mac - Virtiofs (beta)
CPU
macOS 13