同一主机上两个 Docker 容器之间的慢速 Resilio 同步
Slow Resilio Sync between two Docker containers on same host
我正在同一台主机上使用两个 docker containers 测试 Resilio(以前称为 BitTorrent)同步,我注意到通过绑定装载添加文件时同步文件非常慢。
第一个 Resilio 容器:
docker run -d --name resilio1 -p 81:8888 -p 55555:55555 -v /c/Users/Test/resilio/resilio1/config:/mnt/sync -v /c/Users/Test/resilio/resilio1/data:/mnt/mounted_folders/data --restart on-failure resilio/sync
第二个 Resilio 容器(我已更新配置以侦听端口 55556 以避免与 resilio1 发生冲突):
docker run -d --name resilio2 -p 82:8888 -p 55556:55556 -v /c/Users/Test/resilio/resilio2/config:/mnt/sync -v /c/Users/Test/resilio/resilio2/data:/mnt/mounted_folders/data --restart on-failure resilio/sync
将小文件添加到绑定安装到容器中的主机目录时,即使是小文件也需要大约 10 分钟才能同步。
相反,如果我 docker exec 进入容器并创建文件或文件夹,同步会立即发生。
我在这里遗漏了什么吗?
Resilio Sync 使用两种机制来跟踪文件系统中的更改:
- Resilio Sync 订阅的文件系统通知(以立即获取有关文件系统更改的信息)。这些通知只是一个 OS 内核机制,例如 Inotify API 用于 Linux。
- 定期重新扫描同步中添加的所有文件夹(默认情况下每 10 分钟发生一次,可以在 settings 中配置)
如您所知,Docker 在 Windows 上使用 Linux VM and relies on SMB/CIFS support in Linux kernel. As Jochem Kuijpers mentioned the issue is related to a file system notifications which don't work properly in case of Windows and mounted volumes and this is a known issue。
解决方法是使用一些第 3 方工具来跟踪已安装 windows 卷的变化并通知 Docker 容器。
你可以用docker-windows-volume-watcher举例。安装非常简单(脚本需要安装在Windows):
pip install docker-windows-volume-watcher
用法也很简单:
docker-volume-watcher <container_name> C:\path\to\mounted\directory
正如文章所说:
The script will inspect all running containers and start notifying
containers about changes in mounted directories. The script will also
listen container start/stop events and update the list of watched
directories.
我正在同一台主机上使用两个 docker containers 测试 Resilio(以前称为 BitTorrent)同步,我注意到通过绑定装载添加文件时同步文件非常慢。
第一个 Resilio 容器:
docker run -d --name resilio1 -p 81:8888 -p 55555:55555 -v /c/Users/Test/resilio/resilio1/config:/mnt/sync -v /c/Users/Test/resilio/resilio1/data:/mnt/mounted_folders/data --restart on-failure resilio/sync
第二个 Resilio 容器(我已更新配置以侦听端口 55556 以避免与 resilio1 发生冲突):
docker run -d --name resilio2 -p 82:8888 -p 55556:55556 -v /c/Users/Test/resilio/resilio2/config:/mnt/sync -v /c/Users/Test/resilio/resilio2/data:/mnt/mounted_folders/data --restart on-failure resilio/sync
将小文件添加到绑定安装到容器中的主机目录时,即使是小文件也需要大约 10 分钟才能同步。
相反,如果我 docker exec 进入容器并创建文件或文件夹,同步会立即发生。
我在这里遗漏了什么吗?
Resilio Sync 使用两种机制来跟踪文件系统中的更改:
- Resilio Sync 订阅的文件系统通知(以立即获取有关文件系统更改的信息)。这些通知只是一个 OS 内核机制,例如 Inotify API 用于 Linux。
- 定期重新扫描同步中添加的所有文件夹(默认情况下每 10 分钟发生一次,可以在 settings 中配置)
如您所知,Docker 在 Windows 上使用 Linux VM and relies on SMB/CIFS support in Linux kernel. As Jochem Kuijpers mentioned the issue is related to a file system notifications which don't work properly in case of Windows and mounted volumes and this is a known issue。
解决方法是使用一些第 3 方工具来跟踪已安装 windows 卷的变化并通知 Docker 容器。
你可以用docker-windows-volume-watcher举例。安装非常简单(脚本需要安装在Windows):
pip install docker-windows-volume-watcher
用法也很简单:
docker-volume-watcher <container_name> C:\path\to\mounted\directory
正如文章所说:
The script will inspect all running containers and start notifying containers about changes in mounted directories. The script will also listen container start/stop events and update the list of watched directories.