Speed up Docker for Mac with docker-sync
2 min read
Running webapp on Docker on MacOS can be quite slow, especially when you run multiple containers with file sync from host machine to containers. To help solve this problem when developing on MacOS, one of the solutions we can use is a tool called docker-sync.
This post will guide you step-by-step on how to setup on your local machine
WARNING: You should have experience with Docker and Docker Compose in advance so as to understand the post.
- Docker and Docker Compose must be installed
- A Docker image of your project
- Ruby is installed
gem install docker-sync --no-rdoc --no-ri docker pull eugenmayer/unison:18.104.22.168
docker-sync.yml in the main directory of your project and include the following config in the file.
docker-compose-dev.yml in the main directory
Imagine you have
docker_compose.yml like this and you want to sync file to webapp folder in rails_server with docker-sync
First of all, remove line no 5 and 6 (they are the cause of slow container). Then add the following config to the
If you want to stop then replace
stop . To clean up log and reset docker-sync, use clean .
Start containers with Docker Compose
docker-compose -f docker-compose.yml -f docker-compose-dev.yml up -d
To check if everything is running properly, run
docker ps and check for the containers names with
rails_server . If they exist then hooray, your app is now up and running with docker-sync.
Note: you may want to set alias in
.bashrc/.zshrc the command above for faster typing.
- For source code, go to the GitHub repo
- For deeper understanding and configuration, remember to visit the wiki
- This post is originally from the same post on my Medium: dienbui.medium.com/speed-up-docker-for-mac-.. with little modification.
- Cover image is from perforce.com/sites/default/files/image/2018..