Update deployed Container with Watchtower
I added Watchtower to the current Caddy Docker Compose setup that hosts one of my small side projects: acl-feed.madflex.de (blog post). The same Docker-Compose is running a Caddy Server (for this blog and other static pages) and my GoToSocial playground instance.
To be sure only the acl-feed gets updated I added the Watchtower enable-label. The relevant part of the Docker-Compose file:
# (caddy + gotosocial parts omitted) acl-feed: image: forgejo.tail07efb.ts.net/mfa/acl-feed:latest environment: PYTHONUNBUFFERED: 0 restart: unless-stopped ports: - "127.0.0.1:8000:8000" labels: - "com.centurylinklabs.watchtower.enable=true" watchtower: image: containrrr/watchtower volumes: - /var/run/docker.sock:/var/run/docker.sock command: --debug --http-api-update --label-enable environment: - WATCHTOWER_HTTP_API_TOKEN=some-token-here ports: - 8081:8080
The interesting parts are the enable label for the acl-feed, to only activate this one container (for now).
And the commandline parameters for HTTP API and to enable only the labels.
I had to change the port to 8081 instead of 8080, because 8080 is already used.
All ports except 80, 443 and 22 are actually firewalled, so port 8081 is only accessable via Tailscale.
With this curl command the container is updating:
When nothing is there to update the end of the log messages look like this:
level=debug msg="Found a match" level=debug msg="No pull needed. Skipping image." level=debug msg="No new images found for /acl-feed" level=info msg="Session done" Failed=0 Scanned=1 Updated=0 notify=no
And when there is a container to pull, the log messages look like this:
level=info msg="Found new forgejo.tail07efb.ts.net/mfa/acl-feed:latest image (cf0e4574a984)" level=info msg="Stopping /acl-feed (bf60581c76ef) with SIGTERM" level=debug msg="Removing container bf60581c76ef" level=info msg="Creating /acl-feed" level=debug msg="Starting container /acl-feed (09aed1963e85)" level=info msg="Session done" Failed=0 Scanned=1 Updated=1 notify=no
After successfully testing this, I added the curl to the end of the container build in the Forgejo action.
This will automatically trigger a deployment via watchtower when the container was updated.
I described how I built the container for arm64 and amd64 (the latter using QEMU) in an older post.
The step in the Forgejo action that I added for the curl looks like this:
- name: update deployed version run: | curl -H "Authorization: Bearer ${{ secrets.WATCHTOWER_TOKEN }}" \ http://wachtel.tail07efb.ts.net:8081/v1/update
I set the WATCHTOWER_TOKEN variable with the secret I chose in the watchtower compose section.
(In the example above it is some-token-here).
Using watchtower for my small sideproject feels good enough at the moment. And having automatic deployment on Git push without additional infrastructure (except of course Forgejo and a Forgejo Runner) is really nice.




