Files
docker-example/stacks/unicloud-unison/play-with-docker.md
2024-10-20 21:23:12 +08:00

2.5 KiB

unicloud

Unison file sync web interface

examples/client_server_replica/docker-compose.yml

准备

  1. 进入 https://labs.play-with-docker.com
  2. Add new instance 两个
  3. docker pull agarbato1/unison-unicloud:2.53.4

Server

启动服务

mkdir -p /unison-unicloud/data /unison-unicloud/shares
chown -R 1000:1000 /unison-unicloud/data
chmod 777 /unison-unicloud/shares
docker run -d --name unison-unicloud-server \
  -e TZ=Asia/Shanghai \
  --network host \
  -e SERVER_DEBUG=True \
  -e SERVER_UI_USERNAME=admin \
  -e SERVER_UI_PASSWORD= \
  -e ROLE=SERVER \
  --mount type=bind,source=/unison-unicloud/data,target=/data \
  --mount type=bind,source=/unison-unicloud/shares,target=/shares \
  agarbato1/unison-unicloud:2.53.4 \
  bash -c "echo 'Port 2222' >> /etc/sshd_config_debug && exec python3 -u start.py"
检查连接和配置

检查是否能ping通client

CLIENT_IP="192.168.0.17"
docker exec -it server ping -c 1 $CLIENT_IP

检查sshd配置

docker exec -it server cat /etc/sshd_config_debug

查看sshd日志

cat ~/data/log/sshd.log

添加 share1

Client

curl 192.168.0.18:80/status -v

mkdir -p /unison-unicloud/data /unison-unicloud/share
chown -R 1000:1000 /unison-unicloud/data
# chmod 777 /unison-unicloud/share
docker run -d --name unison-unicloud-client \
  -e TZ=Asia/Shanghai \
  --restart on-failure \
  --network host \
  -e CLIENT_HOSTNAME=client_hostname1 \
  -e ROLE=CLIENT \
  -e SERVER_HOSTNAME=192.168.0.18 \
  -e SERVER_PORT=2222 \
  -e SERVER_SHARE=share1 \
  -e API_PROTOCOL=http \
  -e API_PORT=80 \
  -e SYNC_INTERVAL=15 \
  --mount type=bind,source=/unison-unicloud/data,target=/data \
  -e CLIENT_DEST=/share \
  --mount type=bind,source=/unison-unicloud/share,target=/share \
  agarbato1/unison-unicloud:2.53.4
docker logs -f unison-unicloud-client

激活

http://ip172-18-0-23-csabksol2o90009mnang-80.direct.labs.play-with-docker.com/clients,点击ACTIVATE

测试同步

touch /unison-unicloud/share/$(date +%s).txt
docker exec -it server ls /shares/share1