Speeding up Magento Docker dev env

I have several Magento 1.9 development environments running on Docker Compose and Docker Desktop for Mac, both of which have always been slow. Every page reload took 6-10 seconds which really hit productivity.

A friend pointed me to Docker’s settings for bind-mount consistency. By default, when a file is written inside the container, the system waits for that change to be persisted to the host before continuing. The opposite happens for changes written to the host. It’s very quick, but if there are hundreds of changes, it noticeably affects performance.

If you’re willing/able to settle for eventual consistency, things move more quickly. I switched the MySQL data volume to “delegated”, which means the version inside the container is authoritative. That’s where all the MySQL changes happen.

I also switched the Magento filesystem, this time to “cached”. With “cached”, the files on the host system (macOS) are authoritative. It seems unlikely that I’ll manage a manual browser refresh before the macOS change is persisted into the container!

There’s more info about performance of shared volumes in the Docker docs.

Leave a Reply

Your email address will not be published. Required fields are marked *