It's a known issue that Docker for Mac is slow when using shared volumes containing a big amount of files, see docker/for-mac#77.
So, some workarounds came like :cached
and docker-sync. However it's not totally satisfactory because it's still slow compared to native and docker-sync consumes a lot of resources when syncing.
That being said, there is a good alternative, not to say perfect, which is Mutagen. A benchmark is available here. It's almost as fast as native shared volumes with Linux!
This repository shows a configuration with a simple PHP project (Symfony 5 based on symfony-5-docker) but it can be used for any type of project in any language.
Enjoy!
brew install mutagen-io/mutagen/mutagen
docker-compose -f docker-compose.yml -f docker-compose.mac.yml up -d
At the project root directory, execute:
mutagen project start
When using a non-root user in the container you can simply add the following in mutagen.yml:
codebase:
# ...
configurationBeta:
permissions:
defaultFileMode: 644
defaultDirectoryMode: 755
defaultOwner: "myuser"
defaultGroup: "myuser"