1. 程式人生 > >14、CentOS7 安裝Docker之擴充套件(使用BitTorrent Sync分發volumes共享)

14、CentOS7 安裝Docker之擴充套件(使用BitTorrent Sync分發volumes共享)

使用BitTorrent Sync分發volumes

在團隊中試用Docker時,你可能希望能夠在團隊成員之間共享大量資料,不過你可能沒有足夠的空間來搭建一臺共享伺服器。最簡單的方法是當你需要時再從其它團隊成員複製最新的檔案 – 不過在一個更大的團隊中這個方法就不太可行了。
解決方案是使用BitTorrent Sync工具來共享檔案 – 不需要專門的資源。

問題

你想通過internet在主機之間共享volumes。

解決方法

使用BitTorrent Sync映象來共享volume

討論

下圖說明了這個方法是如何運作的。

最終結果是通過因特網方便地同步的卷(/data),不需要任何複雜的設定。
執行如下命令在第一臺主機上設定容器:

[host1]$ docker run -d -p 8888:8888 -p 55555:55555 --name btsync ctlc/btsync

$ docker logs btsync

Starting btsync with secret: ALSVEUABQQ5ILRS2OQJKAOKCU5SIIP6A3

By using this application, you agree to our Privacy Policy and Terms.

http://www.bittorrent.com/legal/privacy

http://www.bittorrent.com/legal/terms-of-use

total physical memory 536870912 max disk cache 2097152

Using IP address 172.17.4.121

[host1]$ docker run -i -t --volumes-from btsync ubuntu /bin/bash

$ touch /data/shared_from_server_one

$ ls /data

shared_from_server_one

在第二個伺服器,開啟一個終端執行這些命令來同步volume:

[host2]$ docker run -d --name btsync-client -p 8888:8888 -p 55555:55555 ctlc/btsync ALSVEUABQQ5ILRS2OQJKAOKCU5SIIP6A3

[host2]$ docker run -i -t --volumes-from btsync-client ubuntu bash

$ ls /data

shared_from_server_one

$ touch /data/shared_from_server_two

$ ls /data

shared_from_server_one  shared_from_server_two

回到第一臺主機執行的容器,你應該能看到第二臺主機的建立的檔案了:

[host1]$ ls /data

shared_from_server_one  shared_from_server_two

 

 

轉載地址:https://www.centos.bz/2016/11/distributed-docker-volumes-with-bittorrent-sync/