Please note if you are using DSM7.2 or higher you should use the Container Manager version of this guide from the menu.
This guide has reached the end of its updates as most people are now on the latest DSM update - This guide is correct as of 08/12/2023 however no further updates will be added.
Important or Recent Updates
Historic Updates | Date |
---|---|
New guide released | 31/12/2021 |
Added command to only include specific containers (thanks to TimeLord on Discord) | 01/09/2022 |
Added notes in relation to updating GlueTUN and Torrents | 03/12/2022 |
Added the missing ‘synobridge’ network | 16/01/2023 |
Compose version number removed and small wording amendments | 09/04/2023 |
Amended the path to save the compose file – this is for security, so the container has no access to the file contents. | 14/04/2023 |
Added labels to GlueTUN container guide so updated information in this one to coincide | 06/05/2023 |
Added a 3rd option to just exclude specific containers via a label. | 23/11/2023 |
What is Watchtower?
Watchtower is an application that watches for updates for all your containers and automatically updates them for you.
Let’s Begin
Watchtower requires access to the Docker socket, we are unable to set this up via the Synology GUI. This means we will be using Docker-Compose.
Docker Compose
We will be using Docker Compose to set up the container. In a nutshell we will be creating a text file (YAML formatted) which tells Docker exactly how we want to set up a specific container.
The next steps can be done either using a code/text editor such as Notepad++ or to keep things simple for this guide we will be using the Synology Text Editor which can be installed from the Package Center.
Open up Text Editor and click on File then New to start a new file.
We have a couple of different composes available below the first one is configured to update all running containers at 2am daily (UTC).
services:
watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
environment:
- TZ=YOURTIMEZONE
- WATCHTOWER_CLEANUP=true
- WATCHTOWER_INCLUDE_STOPPED=true
- WATCHTOWER_REVIVE_STOPPED=false
- WATCHTOWER_SCHEDULE=0 0 2 * * *
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
As an addition to the method above you can exclude specific containers from updates by adding this line to their yaml (compose) details. This is likely faster than using method 2
labels:
- com.centurylinklabs.watchtower.enable=false
The second has an added section where you can specify the names of the containers you would like to update (use the exact name of the container as per the Synology UI)
You can copy and paste the one you wish to use into the new text file, it is important you don’t change the spacing as YAML has to be formatted correctly in order to be read by Docker Compose.
services:
watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
environment:
- TZ=YOURTIMEZONE
- WATCHTOWER_CLEANUP=true
- WATCHTOWER_INCLUDE_STOPPED=true
- WATCHTOWER_REVIVE_STOPPED=false
- WATCHTOWER_SCHEDULE=0 0 2 * * *
command: # add or remove the below as required
- nzbget
- overseerr
- plex
- prowlarr
- radarr
- sonarr
- tautulli
- watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
Environment Variables
We need to make some changes in order for watchtower to know what time it is where you are and what we want it to do. You can amend these based on your preferences.
Variable | Value | What it does |
---|---|---|
TZ | Europe/London | Change this to your own timezone |
WATCHTOWER_CLEANUP | true or false | We want to clean up the old docker images, if you don’t turn this on over the course of a few months you will find that the images start to eat a lot of space and they are not even being used. (true or false) |
WATCHTOWER_INCLUDE_STOPPED | true or false | Do you want to update any stopped containers, the container will stay stopped after being updated (true or false) |
WATCHTOWER_REVIVE_STOPPED | true or false | If a stopped container is updated do you want Watchtower to start it up? (true or false) |
WATCHTOWER_SCHEDULE | 0 0 2 * * * | Rather than setting the number of seconds to wait between checks you can set a schedule. The default I use is to check at 2am every day, you can work out your own schedule using a cron schedule generator |
Your final file should look similar to the one shown below, depending on which version you used above.
Saving the Compose File
We now need to save this file into our docker share
Click on File then Save As, navigate to the ‘docker’ share and you need to change the ‘File name’ to watchtower.yml and save it in the ‘docker’ folder.
SSH and Docker-Compose
It’s time to get logged into you Diskstation via SSH, you can do this in the same way as when you obtained your IDs in the ‘Setting up a restricted Docker user‘ guide.
Once you have logged in you will need to give 2 commands, you can copy and paste these one at a time — you will need to enter your password for the command starting with ‘sudo’
First we are going to change directory to where the watchtower.yml is located, type the below and then press enter.
cd /volume1/docker
Then we are going to instruct Docker Compose to read the file we created and complete the set-up the container. Again type the below and press enter.
sudo docker-compose -f watchtower.yml up -d
When the command has completed you should be able to see Watchtower running in the list of containers in the Synology GUI. You can go into the container and within the log you should see that Watchtower is counting down to your next check.
You can now just leave Watchtower running you will never need to manually update your containers again.
FAQ
Q: I keep getting X container has stopped unexpectedly errors!
A: DSM does not know or understand that Watchtower is issuing commands in the background. So it makes the assumption that it was stopped unexpectedly, but we know it was Watchtower doing an update, the same happens if you issue a commands via docker-compose or even Portainer.
Q: Do I need to update Watchtower itself?
A: Nope it updates itself – quite clever really 🙂
Looking for some help, join our Discord community
If you are struggling with any steps in the guides or looking to branch out into other containers join our Discord community!
Buy me a beverage!
If you have found my site useful please consider pinging me a tip as it helps cover the cost of running things or just lets me stay hydrated. Plus 10% goes to the devs of the apps I do guides for every year.
Historic Updates | Date |
---|---|
New guide released | 31/12/2021 |
Added command to only include specific containers (thanks to TimeLord on Discord) | 01/09/2022 |
Added notes in relation to updating GlueTUN and Torrents | 03/12/2022 |
Added the missing ‘synobridge’ network | 16/01/2023 |
Compose version number removed and small wording amendments | 09/04/2023 |
Amended the path to save the compose file – this is for security, so the container has no access to the file contents. | 14/04/2023 |
Attention! Watchtower seems to use the Cron Spring syntax, check this link:
https://productresources.collibra.com/docs/collibra/latest/Content/Cron/co_spring-cron.htm
It needs 6 input parameters.
The Cron expression generator that you linked gives incorrect results!
Hey, very weird as I originally used crontab as it gave 6 parameter options over alternatives. As I knew from the documentation that watchtower required 6.
I will get another one in its place thanks for spotting.
when i go into putty and give this command i get this error back
[Errno 2] No such file or directory: ‘./watchtower.yml’
And i know for sure the fil is there caus i put it there myself as yaml file
Any thoughts please?
Hey apologies – not sure how I missed this, but I changed the command but the directory you saved the file in is /docker/watchtower.. Move it up one folder into /docker. And the command will work. I am fixing the step now.
Hello. I am getting the following error in terminal. What is synobridge?
Creating watchtower … error
ERROR: for watchtower Cannot start service watchtower: network synobridge not found
ERROR: for watchtower Cannot start service watchtower: network synobridge not found
ERROR: Encountered errors while bringing up the project.
Apologies – somehow I managed to remove a first step.
https://drfrankenstein.co.uk/step-3-setting-up-a-docker-bridge-network/
However, it is not required for this guide, so I will remove this line
network_mode: synobridge
Hey I’m not sure if I missed a step but I set up Watchtower to just update all containers but I think that causes it to update gluetun/qbittorrent and now they’re both not restarting. Is there any easy way to restart them or should I just delete and re-follow the guides? I’m not too familiar with how docker containers actually work
Thanks,
Raptaurr
Hey – I recently made some amendments to both this guide and the Gluetun one – see on the Gluetun guide for the label that will exclude it from updates.
Stop and delete Gluetun and any attached containers – then start them again using the docker-compose command and will get you going.
Awesome, thanks so much for the quick reply! The guides are a lifesaver
Okay actually I’m having an error, so I closed/deleted both the gluetun/qbittorrent containers, went back to the Gluetun guide and updated the YML with the new labels. When I tried to re-start through SSH it says “ERROR: for qbittorrent Cannot start service qbittorrent: OCI runtime create failed: container_linux.go:363: creating new parent process caused: container_linux.go:1946: running lstat on namespace path “/proc/10809/ns/net” caused: lstat /proc/10809/ns/net: no such file or directory: unknown”
OK – Gluetun is currently broken use this version below until it is fixed.
image: qmcgaw/gluetun:v3.34.1
Hi Dr, do you have a suggestion on how to adjust the Environment variables or YML file to enable Pushover notifications for Watchtower? I saw a small contirbution on the GitHub page of Watchtower but that was’nt helpful enough for me to get it working unfortunately.
Best, Mark
Hey so it looks like you have to do Pushover notifications via Shoutrrr which is built into Watchtower (Just to note I have not used this myself)
You would add an environment variable of WATCHTOWER_NOTIFICATION_URL= with you then filling in the URL shown at the top of the Shoutrrr page linked below follow the steps to get the required tokens.
https://containrrr.dev/shoutrrr/0.7/services/pushover/
https://containrrr.dev/watchtower/notifications/#shoutrrr_notifications