Skip to main content

Docker Sync: Slash Container Startup Times on macOS

·607 words·3 mins
Author
psilore
Lead developer and systems engineer. Passionate about retro computing, Linux environments, and automation frameworks.

If you are developing inside Docker containers on macOS, you’ve probably faced the dreaded, coffee-break-inducing startup times. Here is how I slashed my container spin-up times from a painful 10 minutes down to just under 4 seconds using Docker Sync.

Docker Sync speed optimization visual
Docker Sync logo and illustration
TL;DR: Docker on macOS runs inside a virtual machine, leading to massive file system sharing overhead. Docker Sync resolves this by bypass-mounting with high-speed file synchronization.

I hit a brick wall when I was thrown into a development environment that was containerized to the bone. Having almost zero Docker experience, I felt like a five-year-old who was handed A Practical Guide to the UNIX System and expected a coloring book.

The tinkerer in me shouted, “This is even better! More buttons to push!” Fast forward to today, after spending some real time in the codebaseβ€”the initial excitement has definitely worn off.

It was taking 10 minutes to start a clean project. Ten minutes! That couldn’t be right. I usually never question why things seem broken, but this was unbearable. That is when I found the solution: Docker Sync.


The Problem: macOS Virtualization Overhead
#

So, what exactly was causing the bottleneck?

On macOS and Windows, Docker runs inside a virtualized Linux VM. Because of this, standard volume sharing (bind mounts) incurs a massive performance penalty during file-read and file-write operations.

Whenever I rebuilt containers, updated packages, or tested code changes (and inevitably wrote new bugs πŸ˜‰), the volume synchronization took up to 10 minutes. It was incredibly tedious.

Here is the solution that worked for me.


Directory Structure
#

Here is how the project example is laid out:

vanilla/                        # β†’ Root of example 
β”œβ”€β”€ docker/                     # β†’ Data for containers
β”‚   └── strapi         
β”œβ”€β”€ src/                        # β†’ Source files
β”‚   └── Source files  
β”œβ”€β”€ .env                        # β†’ Environment files
β”œβ”€β”€ .docker-compose-dev.yml     # β†’ Setup files for editor overrides
β”œβ”€β”€ .docker-sync.yml            # β†’ Basic sync configuration
β”œβ”€β”€ .docker-compose.yml         # β†’ Base services configuration
└── README.md                   # β†’ Project documentation
In this walkthrough, we will only sync the web server and CMS folders. Database syncing is a bit different and is a topic for a future post.

Installation & Setup
#

Follow these six steps to get Docker Sync up and running.

1. Install Docker Sync
#

Run the gem installation command in your terminal:

gem install --user-install docker-sync

2. Configure docker-sync.yml
#

Create a .docker-sync.yml file in your root folder:

version: "2"
syncs:
  vanilla:
    notify_terminal: true
    src: "./"
    sync_excludes: [".git", ".idea", "node_modules"]

3. Create a Developer Compose Override
#

Create a .docker-compose-dev.yml file to define the sync volume mounts:

version: "2"
services:
  nginx: 
    volumes:
      - vanilla:/app:nocopy
  strapi: 
    volumes:
      - vanilla:/app:nocopy

volumes:
  vanilla:
    external: true

4. Initialize and Run the Sync Stack
#

Launch the synchronization daemon and stack:

docker-sync-stack start

5. Run in the Background
#

Alternatively, run only the sync daemon in the background:

docker-sync start

6. Start Your Containers
#

Wait for the initial sync to finish, then launch your project with both compose files:

docker-compose -f docker-compose.yml -f docker-compose-dev.yml up

The Results
#

In my setup, container build speeds dropped from 4 minutes down to 3–4 seconds.

While 4 minutes doesn’t sound like eternity, those times add up quickly when you are doing clean rebuilds or testing fresh branches.

Pro Tip: If you’re doing clean checkouts or switching git branches frequently, those saved minutes will quickly translate into hours of recovered productivity.

Special thanks to freepik for the awesome icons!


What’s your setup?
#

Have you transitioned to newer virtualization frameworks like VirtioFS in Docker Desktop, or are you still utilizing Docker Sync? Let’s discuss in the comments below!