Introducing Watchtower: Auto Update Your Containers Easily

Watchtower in Proxmox LXC!!!

Harish Thangadurai
4 min readMay 12, 2024

In the previous article, we delved into the step-by-step process of installing Netdata in our Home Lab.

Now we’ll shift gears and take a look into another tool that can auto-update our containers in our Home Lab at ease — Watchtower.

What is Watchtower?

Watchtower is a lightweight, open-source tool designed to automate the process of updating Docker containers. It continuously monitors your Docker environment for changes in image versions and automatically pulls and updates containers to the latest available version without manual intervention.

Key features of Watchtower include:

  1. Automated Updates
  2. Customization
  3. Email Notifications
  4. Security
  5. Ease of Use

Steps to install Watchtower:

  • We’ll be using Portainer Stack to install Watchtower in our Home Lab. First, let us log in to our Portainer instance and then head to our local instance by clicking on the local option.
  • Here we can use the Stack option to deploy our Watchtower instance using our docker-compose file. Let’s click on the Stacks option.
  • We can click on the Add Stack button on the top right corner to create a new stack.
  • We can give the name of the stack, then copy and paste the below docker-compose file of our Watchtower instance.
version: "3"
services:
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- WATCHTOWER_NOTIFICATIONS=email
- WATCHTOWER_NOTIFICATION_EMAIL_TO=
- WATCHTOWER_NOTIFICATION_EMAIL_FROM=
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER=
- WATCHTOWER_NOTIFICATION_EMAIL_PORT=
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=
- WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=
hostname: watchtower
command: --cleanup --interval 10800
restart: always
  • Now there are a couple of configuration options that we can change here. We will be able to send out email notifications if there are any updates available and if the containers are updated. Those details can be defined in the environment section of the docker-compose file. There are other notification options as well. This environment section can be removed completely if there is no notification usage.
  • Now in the commands section ‘ — cleanup’ command is used to remove the previous old images of the container once the new image has been pulled and the container has been updated to save storage space.
  • The ‘ — interval’ command is used to specify the duration in seconds based on which our Watchtower instance would check for updates. Here we have given it as 10800 which is 3 hours.
  • Feel free to change the docker-compose file based on your needs.
  • Once done we can click on the Deploy the Stack button to deploy our Watchtower instance.
  • We can see that the stack has been successfully created. On viewing it, we can see that our Watchtower instance has been successfully installed and the container has started running.

We have now successfully installed and configured our Watchtower instance. Now Watchtower will periodically check for updates of all the images and update the containers accordingly.

However, it is not recommended to use Watchtower on containers that are not stable as they may induce breaking changes frequently which would require manual intervention. If those containers are auto-updated then we may have data loss in a few cases.

In this article, we have explored Watchtower and went into the step-by-step process of deploying the same in our Home Lab.

In the next article, we will be looking into another service that we will be deploying in our Home Lab. Stay tuned for more detailed instructions on expanding our Home Labbing capabilities.

Happy Homelabbing!!!

--

--

Harish Thangadurai
Harish Thangadurai

Written by Harish Thangadurai

👨‍💻 Automation Engineer | 🌍Tech Explorer | 🧠 Lifelong Learner

No responses yet