May 1, 2021

Watchtower: Automate Docker Container Updates

Virtualization, and containerization in particular have been an incredible boon in technology over the past several years. It hasn't come without its drawbacks though, one of which is that it may be just a bit less evident how to keep software up to date inside containers.

Enter Watchtower. This little tool will watch over your containers and update them for you automatically, stopping them gracefully and relaunching them with the same parameters as before.

To use Watchtower, make sure you already have Docker and Docker Compose installed. Then go ahead and throw the Watchtower configuration into a Docker Compose file:

cd /home/YourUser/Docker/ && mkdir Watchtower
cd Watchtower && sudo nano docker-compose.yml
    image: containrrr/watchtower
    container_name: Watchtower
    restart: always
      - /var/run/docker.sock:/var/run/docker.sock
    command: --interval 30

Start the container with:

docker-compose up -d

That's it! From now on, Watchtower will keep a watchful eye on your containers and make sure they stay up to date. If you haven't already set it up, we highly recommend using Portainer, you can head over to its container dashboard and see that Watchtower has appeared in the list, and click the Logs quick action to see what it's doing.

We hope you found this helpful! Please share, and contact us if you have any feedback.