Skip to content

Instantly share code, notes, and snippets.

@faizzed
Last active August 9, 2020 12:48
Show Gist options
  • Save faizzed/ad98d321cc214037afbc0a9f27d079ed to your computer and use it in GitHub Desktop.
Save faizzed/ad98d321cc214037afbc0a9f27d079ed to your computer and use it in GitHub Desktop.
Setting up docker sync on MAC

Install docker-sync

sudo gem install docker-sync

Add docker-sync volumes

docker-sync.yml

version: "2"
syncs:
  
  container-a-volume:
    notify_terminal: true
    src: './../path-to-volume-on-host'
    sync_excludes: ['.git', '.idea', 'node_modules']
    sync_userid: '0' # This is important for permission reasons, 0 is root id, becuase docker-sync uses root for creating volumes. More on this https://github.com/EugenMayer/docker-sync/issues/33
  
  container-b-volume: # mysql etc
    notify_terminal: true
    src: './database/shared-data'
    sync_excludes: ['.git', '.idea', 'node_modules']
    sync_userid: '999' # mysql user id, edit accordingly

Instruct docker-compose to use the above volumes and not the volumes created by docker on MAC

docker-compose-dev.yml

version: "3"
services:

  mysql:
    volumes:
      - container-b-volume:/var/lib/mysql:nocopy

  php:
    volumes:
      - container-a-volume:/var/www:nocopy
      
volumes:
  container-a-volume:
    external: true
  container-b-volume:
    external: true

Run docker-sync

docker-sync start This will create two containers for the volumes and start syncing the files. May take sometime on the first run, afterwards it takes a moment.

Stop docker-sync

docker-sync stop

Edit some settings and reboot docker sync to refresh settings

docker-compose down && docker-sync clean && docker-sync start

ref post https://dev.to/kovah/cut-your-docker-for-mac-response-times-in-half-with-docker-sync-1e8j

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment