The 4.6 release of Docker Desktop for Mac contains a number of changes that drastically improve file sharing performance for macOS users. Firstly, developers now have the option of using a new experimental file sharing implementation called virtiofs (the current default is gRPC-FUSE). Secondly, improvements have been made to the way that files are synced between the macOS host and Docker VM. During testing with our amazing macOS community of users, we have observed that these changes have reduced the time taken to complete filesystem operations by up to 98%.
For developers, these incredible gains in speed mean less time waiting for filesystem operations to complete (or building project-specific workarounds to improve performance) and more time focusing on innovation!
Understanding common developer workflows
A common developer workflow when using technologies like Symfony or React is to edit source code located on the macOS host while running the app itself in a Docker container. The source code is shared between the host and the container by using Docker volumes, with a command like the following:
docker run -v /Users/me:/code -p 8080:8080 my-symfony-app
This allows the developer to edit their source code, save the changes and immediately see the results in their browser. Changes made to files located on the host system must propagate quickly and reliably to the container file system for the developer to optimize productivity and have a good user experience. This is where file sharing performance is absolutely critical.
Big performance improvements
Performance is vital when application source code is shared between the host and container. For example when a developer uses the Symfony PHP framework, edits the source code and then reloads the page in the browser, the web-server in the container must re-read many PHP files stored on the host. When considering that modern dependency management can easily bring 10k – 100k files into a project (which linearly increases the performance penalty), this can result in poor performance as the host and container keep in sync via the volume.
The recent changes to Docker Desktop for Mac, including the usage of virtiofs, alleviate this problem and bring drastic improvements to file system performance. Specifically, developers working with an early preview of Docker Desktop 4.6 with virtiofs enabled and changes to file syncing included have observed:
And here are some of the comments we’ve heard from users:
- “This works great on my mac mini M1!, running migrations on my laravel instance is now instant…instead of running for minutes.” (Source: Github user feedback)
- “My development setup is ridiculously fast now. Thanks everyone!” (Source: Github user feedback)
- “Looking forward to seeing this enhancement land in a released build. It was like night and day! 🙌.” (Source: Github user feedback)
How to enable virtuals
Virtiofs is only available to users of the following macOS versions:
- macOS 12.2 and above (for Apple Silicon)
- macOS 12.3 and above (for Intel)
To enable virtiofs in Docker Desktop:
- Ensure that you are using Docker Desktop version 4.6, available here
- Navigate to ‘Preferences’ (the gear icon) > ‘Experimental Features’
- Select the ‘Use the new Virtualization framework’ and ‘Enable VirtioFS accelerated directory sharing’ toggles
- Click ‘Apply & Restart’
Your feedback is needed!
Virtiofs is accessible today within Docker Desktop for Mac (version 4.6) and available to all users including Docker Personal free users as well as Docker Pro, Team and Business paid subscription users.
Please download it, give it a try and let us know how it goes. If you discover any problems, please report them on the Mac filesystem performance thread on our public roadmap. For the moment, we are aware of an outstanding issue where containers running with virtiofs can fail due to permission errors. We have released a fix for this in an experimental desktop build to the Mac filesystem performance thread and will confirm its stability in the coming days.
Likewise, we’re always interested to hear of any performance benchmarks that you may use to test out virtiofs !
Download button for Desktop 4.6
We’d like to say a massive thank you to our macOS community of users for providing brilliant feedback and testing out the feature so rigorously. In particular, the excellent analysis of file system performance conducted by Konstantinos Tsanaktsidis led to valuable insights around file syncing.