Introduction
When it comes to managing and updating Docker containers, it can often feel like a time-consuming process to keep everything running smoothly. That's where WatchTower comes in. It's an open-source tool that automates the process of monitoring and updating your Docker containers. In this post, I’ll walk you through setting up WatchTower using Docker Compose, and I'll explain how it can save you time while keeping your environment reliable and up-to-date. Whether you’re managing a few containers or dozens, WatchTower offers a practical solution for automating updates without constant manual intervention.
One of the things I like most about WatchTower is how easy it makes container maintenance. For example, it can automatically pull updates for your running containers and restart them for you. If you have critical services that need to stay on a specific version, you can exclude them from updates using simple labels. WatchTower also supports useful features like environment variable customization, which allows you to tailor its behavior to suit your specific needs. With just a little bit of setup, you’ll have a tool that works quietly in the background, ensuring your containers are always up-to-date.
This guide will cover everything you need to get started, from configuring the docker-compose.yml
file to setting up container exclusions. I’ve also included tips on managing environment variables and ensuring you have the right prerequisites in place. My goal is to make this process as straightforward as possible so you can focus on other important tasks. By the end of this post, you’ll have a solid understanding of how to use WatchTower effectively—and why it’s such a valuable tool for anyone using Docker regularly.
References


Prerequisites
- Internet Connection
- Up-to-date Server
- Proper permissions to run Docker commands
- Docker Setup - Ultimate Docker Guide
Overview
WatchTower is a super useful tool for automating Docker container updates. It keeps your containers up-to-date without you needing to manually intervene every time there's an update. Essentially, it monitors your running containers and pulls updates for them when available, restarting them automatically. This is a huge time-saver, especially if you're managing multiple containers.
One of the coolest features is the ability to exclude specific containers from being updated, which can be a lifesaver if you have critical services that need to stay on a fixed version. There’s also support for setting environment variables to tweak how WatchTower behaves. Best of all, it's completely free and open-source, so there are no paid features to worry about. If you’re using Docker regularly, WatchTower can make your life much easier.
Container Setup
docker-compose.yml
cd /data
mkdir watchtower
cd watchtower
nano docker-compose.yml
services:
watchtower:
container_name: watchtower
image: containrrr/watchtower
restart: always
environment:
WATCHTOWER_CLEANUP: true
WATCHTOWER_LABEL_ENABLE: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
Use Control+O
to save and Control+X
to exit. Run the container using docker compose up -d
.
Exclude Containers
If you don’t want containers to be watched, you can exclude them by adding the following label when starting them. Look at the examples below:
docker run -d --label=com.centurylinklabs.watchtower.enable=false someimage
version: "3"
services:
someimage:
container_name: someimage
labels:
- "com.centurylinklabs.watchtower.enable=false"
Conclusion
Setting up WatchTower for Docker is a simple yet powerful way to streamline container management and ensure your environment stays up-to-date without constant manual oversight. In this guide, I walked you through the entire process, from configuring the docker-compose.yml
file to excluding specific containers from updates. We explored how WatchTower can monitor your running containers, pull updates, and restart them automatically, saving you valuable time and effort. I also highlighted the importance of environment variable customization and how it allows you to tailor the tool's behavior to fit your specific needs. If you have critical services that require stability, the exclusion feature ensures you maintain control while still benefiting from automated updates.
By implementing WatchTower, you can focus your energy on more complex tasks instead of spending time on routine maintenance. Whether you are managing just a few containers or an entire fleet, this tool is a solid, reliable solution for keeping Docker environments efficient and secure. I hope this post has been helpful in breaking down the process and showing you how to leverage WatchTower effectively. If you’ve followed along, you’re now equipped with the knowledge to maintain your containers effortlessly and keep your Docker setup running smoothly. Dive in, try it out, and see how much easier container management can be.
Full Disclosure
Most of this article is comprised of facts and opinions. AI (specifically Grok and Notion AI) was used in the creation of this post. The featured background image was created by andyoneru and is available on Unsplash. I added a blur and a gradient overlay with some text. The following images have been pulled or screenshotted from the respective websites/applications. I do not own this content.