Nicolas Bouliane

Why Docker for Mac is making your website slow Posted on

When I was rebuilding my personal website, pages loaded extremely slowly, especially in the Craft CMS admin. This was odd, since it used the exact same stack as All About Berlin, which is ridiculously fast.

Is this your problem?

If that’s the case, your problem is probably the same as mine.

The problem and the solution

Volumes in Docker for Mac are really slow. This is a known issue. When your Docker machine accesses files on a mounted volume, it slows everything down. If your website’s scripts or static assets are in a volume, your pages will load slowly.

In my case, Composer’s vendors directory was in a volume, so every page load touched a dozen PHP files very slowly. On my other websites, the vendors directory was in a different location.

The solution is to copy files onto the docker machine, instead of mounting them as a volume. There are other ways to make volumes faster on OS X, depending on your situation.