Keeping Docker Containers up to date with Watchtower

Rather than manually updating the few services I'm running in docker, I setup watchtower to take of this automatically. This is mostly here for myself as notes and may not be up to date, but it might help you too.

My docker host is currently a Synology NAS and here are the steps I followed it set this up.

After sshing into the NAS, as root, I created the following script at /root/scripts/install-watchtower:

#!/usr/bin/env bash

docker run -d --name=watchtower \
	-v /var/run/docker.sock:/var/run/docker.sock \
	--restart=always \
	containrrr/watchtower --cleanup

Then I can make it executable chmod +x install-watchtower and run it with ./install-watchtower. This will get it running in docker.

I sometimes want to be able to force an update, so I also have the following script at /root/scripts/run-watchtower:

#!/usr/bin/env bash

docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock \
    containrrr/watchtower --run-once

#docker #selfhosting