From 429672e0b4b8ff0978924fdd0a06b90cccf59773 Mon Sep 17 00:00:00 2001 From: maxice8 <30738253+maxice8@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:53:13 -0300 Subject: [PATCH] docs(docker): add healthcheck to docker-compose (#9742) ### Purpose Syncthing had a healthcheck API for a while, and the example Dockerfile for it has it in the form of: HEALTHCHECK --interval=1m --timeout=10s \ CMD curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1 Let's add it to the docker-compose as well ### Testing I use this docker-compose.yml file to deploy via ansible (using community.docker.docker_compose_v2) to my machine with success, using `wait: true` in ansible for it to use `docker compose up --wait`. ```yml - name: Enable syncthing docker community.docker.docker_compose_v2: project_src: /srv/syncthing wait: true wait_timeout: 90 ``` --- README-Docker.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README-Docker.md b/README-Docker.md index 02b0dc5d7..5d7a736c3 100644 --- a/README-Docker.md +++ b/README-Docker.md @@ -49,6 +49,11 @@ services: - 22000:22000/udp # QUIC file transfers - 21027:21027/udp # Receive local discovery broadcasts restart: unless-stopped + healthcheck: + test: curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1 + interval: 1m + timeout: 10s + retries: 3 ``` ## Discovery @@ -84,6 +89,11 @@ services: - /wherever/st-sync:/var/syncthing network_mode: host restart: unless-stopped + healthcheck: + test: curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1 + interval: 1m + timeout: 10s + retries: 3 ``` Be aware that syncthing alone is now in control of what interfaces and ports it