Updating Docker Containers on Raspberry Pi with Watchtower

In this quick tutorial, we will show you how to run Watchtower on your Raspberry Pi.

Raspberry Pi Watchtower

Watchtower is an incredibly useful tool that allows you to keep your Docker containers updated easily.

It achieves this by monitoring when new images are available and automatically downloading and moving your containers to the latest version.

This ability to self-update can be great for those who like to minimize the amount of time they spend doing maintenance on their Raspberry Pi. Best of all, Watchtower can be installed and set up on your Pi in just a few short steps.

Of course, you should always be careful about having a tool like Watchtower update software you can’t afford to go down. While there shouldn’t ever be any issues with the update process, there is always the chance that a container provider will make a breaking change.

Luckily, Watchtower allows you to configure which containers are automatically updated. This allows you to not update any software you can’t afford to have go offline.

Equipment

Below is a list of equipment we used when setting up the Watchtower software on our Raspberry Pi.

Recommended

Optional

This tutorial was last tested on a Raspberry Pi 5 running the latest version of Raspberry Pi OS Bookworm.

Installing Watchtower to your Raspberry Pi

Over the following sections, we will walk you through the simple process of setting up and running Watchtower on your Raspberry Pi.

This is one of the easiest containers to run, requiring little to no configuration. Out of the box, this tool will automatically check for updates every 24 hours.

Preparing your System to run Watchtower

1. Before we begin, let’s use the following two commands to ensure our Raspberry Pi is completely up to date.

The first command updates the package list cache. The second upgrades any out-of-date packages.

sudo apt update
sudo apt upgrade -y

2. Next, for Watchtower to work and for it to be of any use, you will need to have Docker installed on your system.

If you haven’t yet done this, be sure to follow our guide on installing Docker to the Raspberry Pi.

Creating Folders for the Watchtower Container

3. With your Raspberry Pi ready, we can create a directory to store the Compose file for Watchtower.

You can use the mkdir command within the terminal to create this directory.

sudo mkdir -p /opt/stacks/watchtower

4. Since we need to be in this newly created directory, we can change into it using the cd command.

cd /opt/stacks/watchtower

Writing a Compose File for Watchtower on the Raspberry Pi

5. Once you are in the “watchtower” directory we created, we can move on.

Our next step is to write a Docker Compose file for Watchtower on our Raspberry Pi. You can begin writing this file using the following command.

We choose to use the nano text editor

sudo nano compose.yaml

6. Now, within this file you must enter the following lines.

These lines are very simple. They basically just tell Docker to download Watchtower and mount the Docker socket so that the container can communicate with the runtime.

version: '3.7'

services:
  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

7. By default, Watchtower will automatically update any container running on your Raspberry Pi.

If you only want particular containers to be automatically updated, you will want to add the following line to your compose file.

Replace “” with the name of the container you want watched. You can specify multiple containers by adding a space between each one.

    command: 

8. Once you have finished filling out the file, save and quit by pressing CTRL + X, Y, and then ENTER.

Starting Watchtower on your Raspberry Pi

9. With the Compose file written, starting Watchtower on our Raspberry Pi is as easy as running the command below.

Docker will download the Watchtower image and start it immediately. Once 24 hours have passed, Watchtower will automatically update any out-of-date Docker containers.

docker compose up -d

Conclusion

By this point in the tutorial, you should have Watchtower installed on your Raspberry Pi and it up and running.

This tool is super helpful for keeping your containers updated. This is especially true when it’s a device you want to just set and forget but want to avoid running old and potentially insecure software versions.

Of course, there are risks to using a tool like Watchtower, such as that a piece of software gets broken by a new update due to new configuration requirements.

Please feel free to leave a comment below if you have any questions about using this tool on your device.

If you found this tutorial helpful, we highly recommend checking out our many other Raspberry Pi projects.

Print Friendly, PDF & Email

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Server Status

Aradippou Chat 1 Chat 2 Larnaca Limassol Nicosia

Chat Links

Official Links.

1. Chat 1.
2. Chat 2.

Alternative Mirror Links.

1. KiwiIRC 1.
2. KiwiIRC 2.

Other Web Clients.

1. IrcCloud.

Recent Posts

Related Posts:

Advertisement

Archives

Super Club Radio

Mighty Deals

CyIRC

CyIRC Tweets

Scroll Up
Fatal error: Uncaught WMAC\JSMin_UnterminatedStringException: WMAC\JSMin: Unterminated String at byte 1180: "+o.accessToken}}).then(e=>{if(!e.ok)throw e;return e});return a.catch(e=>{console.error(`Failed to logout chatrix session. deviceId: ${o.deviceId}`)}),a}})(); in /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/ext/php/jsmin.php:215 Stack trace: #0 /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/ext/php/jsmin.php(157): WMAC\JSMin->action(2) #1 /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/ext/php/jsmin.php(96): WMAC\JSMin->min() #2 /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/class-main.php(375): WMAC\JSMin::minify('(function(){"us...') #3 /home/bszucbfe/public_html/wp-includes/class-wp-hook.php(324): WMAC_PluginMain->jsSnippetcacher('(function(){"us...', '/home/bszucbfe/...') #4 /home/bszucbfe/public_h in /home/bszucbfe/public_html/wp-content/plugins/clearfy/components/minify-and-combine/includes/classes/ext/php/jsmin.php on line 215