At the beginning we were using dinghy with NFS file sharing . The performances weren’t very good and we weren’t achieving native linux perfs but it was quite acceptable.
Then Docker released Docker-For-Mac and we naively switched to the official Docker tool for the Mac OS. Unfortunately we faced a BIG issue with filesystem bind mount : https://github.com/docker/for-mac/issues/77. As we mainly work with PHP projects, especially Symfony or Magento ones, with tens of thousands of PHP files, we were devastated because of the very poor performances …
Like many other PHP developers we found a workaround: Docker-sync. This tool synchronise your host workspace with a docker volume. It worked quite well, we reached native linux performances, but there were some drawbacks:
- You need to remember to run docker-sync before running your app: We have a wrapping script in order to start docker-sync then the app
- When you switch git branch, in most cases it would be wise to stop the app, use docker-sync clean and re-sync everything, otherwise you could face some problems…
- Sometimes, docker-sync may freeze or stop. It can be very frustrating if you don’t figure it out quickly.
- Because it’s a Mac workaround, it may be wise to have separate docker-compose-osx.yml and run docker compose with an -f flag keeping the original docker-compose.yml as clean as possible, especially if your team, like ours, works with both Mac and Linux.
- Full re-sync can take more than 5 minutes on big PHP projects…
It wasn’t confortable for our developers, and even became more an more frustrating.
Finally Docker-for-mac released a new version with the :cached option on mounted volumes in order to adresse the issue #77. They also planned to release :delegated (see https://github.com/docker/for-mac/issues/1592 and https://blog.docker.com/2017/05/user-guided-caching-in-docker-for-mac/) . It was a really good update, but applications like Magento or Symfony are writing intensively in some directories (for cache or generated code…) and this wasn’t really efficient.
Thanks to https://github.com/dunglas/symfony-docker/blob/master/docker-compose.yaml we figured out the trick to mount docker volumes on the directories where the application is writing intensively. Docker volumes have native linux performances on writing which implies that our apps reached very good performances with this configuration.
We ended up with a docker-compose-osx.yml file written to override default config. Example for a Magento 2 :
Our developers are now happy again 🙂