Trending September 2023 # How Sync Command Works In Docker? # Suggested October 2023 # Top 18 Popular |

Trending September 2023 # How Sync Command Works In Docker? # Suggested October 2023 # Top 18 Popular

You are reading the article How Sync Command Works In Docker? updated in September 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested October 2023 How Sync Command Works In Docker?

Introduction to Docker Sync

Docker sync is a very useful tool to improve the performance of your containerize application about 60 times on Mac or Windows. We are facing performance issues while working on development projects on Mac or Windows because containers run inside a VM on these systems and it degrades the file read/write performance drastically as the file system used by Mac or Windows is different from Linux so containers can not read or write directly to disk instead it depends upon the Mac or Windows kernel.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others


docker sync [COMMAND]


–version, -v: Used to print out the version of docker-sync.

clean: Used to stop and clean up all sync endpoints.

help [COMMAND]: Used to know more about any command.

list: Used to list all sync points of the project configuration path.

logs: Prints the last 100 lines of daemon log, It only works with docker-sync running in the background.

start: Used to start all sync configuration in the project.

stop: Used to stop the docker-sync daemon.

sync: Used to the only sync without starting the watcher.

docker-sync help start


In the above snapshot, we can see that it shows all options available for the ‘docker-sync start’ command.

How Sync Command Works in Docker?

Docker-sync creates a volume and saves all our application source files in that volume that makes it available to our application running as a container which means we need to mount that volume to the container. It uses native mount to access volumes and volumes are not bound to our host (i.e. Windows or Mac) filesystem that is handled by Linux kernel and that allows containers to access our application source code faster.

It uses different sync strategies based on the operating system by default, however, we can mention specific sync strategies in the chúng tôi file.


Let’s understand with examples.

Installation on a Linux machine (Ubuntu):

1. First of all update your system.

apt-get udpate

2. Install ruby and ruby-dev.

apt-get install ruby ruby-dev -y

3. Install gem now.

apt-get install gem

4. Now, install and the below command will work on any platform after installing gem.

gem install docker-sync

5. We will run the below command to check, docker-sync was installed successfully or not.

docker-sync -v

6. Once it is installed successfully. Create a chúng tôi file with the below config and it should be in the main directory.


7. Let’s assume, we have a chúng tôi file with the below configuration.


8. Now, create a chúng tôi file and populate it with the below configuration.


9. Let’s start using the below command.

docker-sync start

Note: When we run this command, it creates a volume with the name mentioned in the ‘docker-sync.yml’ file, we can check it by running ‘docker volume ls’ as shown below.

docker volume ls

docker-compose -f chúng tôi -f chúng tôi up –d

11. If we want to stop the sync, we can use the stop keyword by replacing start as shown below:.

docker-sync stop

12. We can use clean to clear the logs and remove the unused volumes.


In the above example, we can see a Docker volume is created and when we run the clean command it gives us an error that the volume is still in use because those containers are still running so we need to remove the containers first in order to remove those volumes. Mostly, it is used to clear logs, remove stopped containers, or unused volumes created by docker-sync.

13. We can use the ‘list’ command as below to list all sync-points of the project configuration path.

docker-sync list

Advantages of Docker Sync

It is supported for almost all platforms OSX, Windows, Linux, and FreeBSD.

It improves the code execution a lot if running on Docker for Mac and Windows.

It does not require any dependencies on OSX if we use native_osx.

It supports more than one sync-end point and project at the same time.

It also does not bound us to use a specific docker solution as it is for docker-for-mac, docker toolbox, VirtualBox, VMware Fusion, Parallels, or whatever.

Rules and Regulations for Using Sync

The ‘docker-compose’ must be installed on the system to use docker-sync.

The ‘docker-sync clean’ command only removed unused volumes and if the volumes are in use, it throws the error.

It is recommended to update the system before installing the gem.

We should only sync the files that are really needed on the host as well as the client-side.


It is the best tool to avoid slowness issues if running multiple containers on Mac OS or Windows and syncing files from host machines. There are options available while creating chúng tôi to fulfill your requirement.

Recommended Articles

You're reading How Sync Command Works In Docker?

Update the detailed information about How Sync Command Works In Docker? on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!