How Mutagen changed my life

Posted on Nov 11, 2021

I’m running some containers on my Mac: it’s a great way to play around and get ready for my new challenge - more to come in the next months!

Anyway, I noticed that sometimes it’s really slow especially compared to the native environments. In particular PHP apps are performing really bad. After googling a bit I found that it’s a known issue: keeping filesystems in sync it’s always a pain.

One of the available solutions is to switch to Mutagen: I found a great article here.

Mutagen provides real-time file synchronization and flexible network forwarding for developers, extending the reach of local development tools to cloud-based containers and infrastructure.

So, I had to setup mutagen on my Mac - through homebrew - and change the docker-compose.yml setting.

version: '3'

services:
  your-service:
    image: your-image
    volumes:
      - your-mount-point:/your/mount/point

volumes:
  your-mount-point:

x-mutagen:
  sync:
    defaults:
      ignore:
        vcs: true
      mode: 'two-way-resolved'

    your-mount-point:
      alpha: './your/mount/point/'
      beta: 'volume://your-mount-point'

Basically, mutagen will keep your-mount-point volume in sync with the alpha folder, while the container will mount the volume in the target path.

Then I had run the apps with a mutagen compose up - yes, forget about docker compose.

Performance now are great, really close to native environments. Thanks mutagen, you changed my life!