bt-sync / sync-docker

Resilio Sync docker image
https://www.resilio.com
178 stars 59 forks source link

Running Resilio within Docker containers #10

Closed pascalandy closed 5 years ago

pascalandy commented 7 years ago

Hi,

Context

I discovered sync via this project https://github.com/nimmis/docker-btsync. It still works well but nimmis' project is not supported anymore since sync is now Resilio.

So I would prefer to use Resilio from the latest updates :) I'm trying to use the official project within Docker but it's not working yet.

At this point I only want to sync one directory named: pics. I will run another set of container if I want to share more directories.

Question - I guess I'm missing something right ?

///

This is how I would expect this project to work:

On my Linux Server: mkdir -p /mnt/syncdata/sync mkdir -p /mnt/syncdata/pics

On my mac: mkdir -p /Users/andy/Documents/mnt/syncdata/pics mkdir -p /Users/andy/Documents/mnt/syncdata/sync

1) Start the first Resilio (master) container

docker run -d --name syncmaster \
-p 8888:8888 \
-p 55555 \
-v /mnt/syncdata/sync:/mnt/sync \
-v /mnt/syncdata/pics:/mnt/pics \
--restart on-failure \
resilio/sync:release-2.4.4

2) Find the -e RSLSYNC_SECRET

docker exec syncmaster sh -c "cat /var/log/rslsync.log"

Question - I can't find the secret ID at the moment. So I don't understand how Minion nodes can communicate with the master.

_... then copy paste: -e RSLSYNCSECRET=ATLVGBCC4XUL4E7S3ZZ6UNS5Z2SZN2J7Y

3) Start minion containers

docker run -d --name syncminion1 \
-p 8888:8888 \
-p 55555 \
-v /Users/andy_lap/Documents/mnt/syncdata/sync:/mnt/sync \
-v /Users/andy_lap/Documents/mnt/syncdata/pics:/mnt/pics \
--restart on-failure \
resilio/sync:release-2.4.4

or ...

docker run -d --name syncminion1 \
-e RSLSYNC_SECRET=ATLVGBCC4XUL4E7S3ZZ6UNS5Z2SZN2J7Y \
-p 8888:8888 \
-p 55555 \
-v /Users/andy_lap/Documents/mnt/syncdata/sync:/mnt/sync \
-v /Users/andy_lap/Documents/mnt/syncdata/pics:/mnt/pics \
--restart on-failure \
resilio/sync:release-2.4.4

and so on ...

P.S. I don't mind using the GUI at this point.

Cheers! twitter.com/_pascalandy

pascalandy commented 7 years ago

Also, do we need to copy-paste something (like a config) from the first container into other nodes ?

roman-zanin commented 7 years ago

@pascalandy 1) Synd docker image is restricted to "/mnt/sync/folders", "/mnt/mounted_folders" folders inside container, therefore mounting /mnt/pics won't work. 2) Current implementation of Sync docker image only allows to use WebUI to configure folders, it is not designed to used config as it resides inside /etc/ in container. You can attempt to run bash in container and manually adjust config file, though. We plan to change it in future and move config file to /mnt/sync, therefore it'll be accessible from real PC.

pascalandy commented 7 years ago

Thanks for the answer!

I wish the docker community could run only two containers to shuffle files around! Here is my two cents:

Directory to sync on the servers

MNT_myapp=/mnt/syncdata/myapp
mkdir -p $MNT_myapp
cd $MNT_myapp/ && ls -la

1) Master Node

CTN_resilio="resilio_myapp"
#
docker rm -f "$CTN_resilio"
sleep 1
#
docker run -d \
--name "$CTN_resilio" \
-v /mnt/syncdata/myapp:/data \
--restart=always \
-p 55555:55555 \
-e RSLSYNC_TOKEN="fancysecret_deb0e8cMmUzMG71baYTRc2a2806eac1e8MGQMzM3ZGQ3N2RlNDlmYmM" \
-e RSLSYNC_ROLE=master \
resilio/sync:2.4.4
#
sleep 4
docker logs -f $CTN_name

# Check the state of resilio in the logs. 
# Should be ready to sync with other containers.

2) Minion Nodes

CTN_resilio="resilio_myapp"
#
docker rm -f "$CTN_resilio"
sleep 1
#
docker run -d \
--name "$CTN_resilio" \
-v /mnt/syncdata/myapp:/data \
--restart=always \
-p 55555:55555 \
-e RSLSYNC_TOKEN="fancysecret_deb0e8cMmUzMG71baYTRc2a2806eac1e8MGQMzM3ZGQ3N2RlNDlmYmM" \
-e RSLSYNC_ROLE=minion \
resilio/sync:2.4.4

# Check the state of resilio in the logs. 
# Should see files that were synced.

What do you think?

Cheers! https://twitter.com/_pascalandy

roman-zanin commented 7 years ago

You can do it with current implementation. Just ensure that the WebUI and listening ports do not intersect on your host.

pascalandy commented 7 years ago

I would love to but I don't see how. I'll be very happy to put this in place :)

roman-zanin commented 7 years ago

Just run instances with different ports. For example, first instance will be started as:

docker run -d --name Sync1 \
  -p 8888:8888 -p 55555:55555 \
  -v $DATA_FOLDER:/mnt/sync \
  --restart on-failure \
  resilio/sync

Second instance as:

docker run -d --name Sync2\
  -p 8889:8888 -p 55556:55555 \
  -v $DATA_FOLDER:/mnt/sync \
  --restart on-failure \
  resilio/sync
pascalandy commented 7 years ago

In your example, how does the server 1 can talk with server 2? No key or anything ?

server 1

docker run -d --name Sync1 \
  -p 8888:8888 -p 55555:55555 \
  -v $DATA_FOLDER:/mnt/sync \
  --restart on-failure \
  resilio/sync

server 2

docker run -d --name Sync2\
  -p 8889:8888 -p 55556:55555 \
  -v $DATA_FOLDER:/mnt/sync \
  --restart on-failure \
  resilio/sync
roman-zanin commented 7 years ago

You can share key via webui of both instances.

pascalandy commented 7 years ago

I tried many many many times. Delays, too many much clicks. Nodes are up and down all the time, so as a docker devops guys, it does work for me :(

I would just love to run this, authorized minions from a token generated by the leader and call it a day.

roman-zanin commented 7 years ago

Got you. You can map one more extra folder, /etc and edit sync.conf file. See here for instructions on config file syntax.

In future, we plan to make it available so no additional mount required.

pascalandy commented 7 years ago

Sounds promising. Please let me know when it's ready :)

01e9 commented 6 years ago

It works fine, thank you for this image! Please keep it up-to-date.


I wan't to share my docker-compose.yml

# simplified example
services:
    my_app:
        # ...
        volumes:
            - "./volumes/app_data:/var/app_data"
    my_app_resilio:
        # ...
        image: resilio/sync
        volumes:
            - "./volumes/resilio:/mnt/sync"
            - "./volumes/IgnoreList:/mnt/mounted_folders/app/.sync/IgnoreList:ro"
            - "./volumes/app_data:/mnt/mounted_folders/app/app_data:ro"