Watchtower on Docker – Automate Docker image updates

Watchtower on Docker – Automate Docker image updates

In this tutorial, let’s learn how to set up watchtower

What is a Watchtower?

  • Watchtower is a container-based solution for automating Docker container base image updates
  • It scans if a new image is available on the registry according the specified interval
  • If a new image is found, it will gracefully shut down your existing container and restart it with the same options that were used when it was deployed initially

Read more here: https://containrrr.dev/watchtower/

How to deploy Watchtower?

Use the below command to deploy watchtower

By default, the scan interval is 24 hours, i.e., watchtower will run a scan for the images every 24 hours. In case it finds a new image it will stop the container, update and re-run the container with the initial options

# -d flag is used to run the container in detached state
# --name specifies the name of the container
# -v /var/run/docker.sock:/var/run/docker.sock the socket will enable watchtower to execute docker commands on the host
# containrrr/watchtower is the image for the container
docker run -d \
  --name watchtower \
  -v /var/run/docker.sock:/var/run/docker.sock \
  containrrr/watchtower

In case you are using a private registry you can pass the username and password as environment variables as shown below

docker run -d \
  --name watchtower \
  -e REPO_USER=username \
  -e REPO_PASS=password \
  -v /var/run/docker.sock:/var/run/docker.sock \
  containrrr/watchtower

Another option instead of passing the username and password as variables is to mount the host configuration file

docker run -d \
  --name watchtower \
  -v /home/<user>/.docker/config.json:/config.json \
  -v /var/run/docker.sock:/var/run/docker.sock \
  containrrr/watchtower

By default, watchtower will monitor all the running containers. However, you can specify the containers that are required to be monitored as shown below
In this example, we are instructing watchtower to only monitor the portainer and duplicati containers

docker run -d \
  --name watchtower \
  -v /var/run/docker.sock:/var/run/docker.sock \
  containrrr/watchtower \
  portainer duplicati

If you do not need to continuously monitor the containers for updates, you can instruct watchtower to run only once

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

The poll interval can also be manually specified using the -i flag as shown below. In this example, it will run the scan every 100 seconds

docker run -d \
  --name watchtower \
  -v /var/run/docker.sock:/var/run/docker.sock \
  containrrr/watchtower \
  -i 100

Congratulations!! You have successfully set up Watchtower on Docker

3570cookie-checkWatchtower on Docker – Automate Docker image updates

40 Comments

  1. Avatar D Shridhar Reddy

    Enjoying the docker and please do write on Kafka will be helpful.

  2. Avatar บาคาร่า

    Hello there! I could have sworn I’ve been to this website before but after
    browsing through some of the post I realized it’s new to me.
    Anyhow, I’m definitely happy I found it and I’ll be bookmarking and checking back
    frequently!

  3. I have read so many articles or reviews about the blogger lovers
    however this paragraph is in fact a fastidious post, keep it up.

  4. This is a topic which is near to my heart…
    Thank you! Exactly where are your contact details though?

  5. It is the best time to make some plans for the future and it’s time to be happy.
    I have read this post and if I could I desire to suggest
    you some interesting things or suggestions.
    Maybe you could write next articles referring to this article.
    I want to read even more things about it!

  6. whoah this blog is fantastic i really like studying your posts.Keep up the good work! You recognize, many persons are searching round for this information, you could help them greatly.

  7. Avatar judi slot online

    Very neat blog.Much thanks again. Really Great.

  8. We’re a group of volunteers and starting a new scheme in our community.
    Your website offered us with valuable info to work on. You’ve done an impressive job and our whole community will be grateful to you.

  9. Hello, its nice paragraph concerning media print, we
    all be aware of media is a great source of facts.

  10. It’s nearly impossible to find well-informed people for this subject, however, you seem like you know what you’re talking about! Thanks

  11. My brother recommended I may like this web site. He was once totally right.
    This put up actually made my day. You can not imagine simply how a
    lot time I had spent for this information! Thank you!

  12. Someone essentially assist to make seriously articles I might state.

    This is the very first time I frequented your website page and thus far?

    I amazed with the analysis you made to make this actual submit amazing.

    Great task!

  13. Do you mind if I quote a couple of your posts as
    long as I provide credit and sources back to your
    site? My blog site is in the very same area of interest as yours and my
    visitors would genuinely benefit from some of the information you provide here.
    Please let me know if this okay with you. Thanks
    a lot!

  14. You ought to take part in a contest for one of the best sites
    on the internet. I most certainly will highly recommend this web site!

  15. Avatar situs judi slot

    I like the helpful information you provide in your articles.
    I’ll bookmark your weblog and check again here frequently.
    I am quite certain I will learn lots of new stuff right here!

    Good luck for the next!

  16. Im grateful for the blog post.Much thanks again. Will read on…

  17. Avatar lillian_canela

    Thanks in favor of sharing such a fastidious idea, post
    is pleasant, thats why i have read it fully

  18. Avatar juniper bonsai turning yellow

    I’m curious to find out what blog platform you have been using?

    I’m experiencing some minor security issues with my latest blog and I
    would like to find something more safe. Do you have any suggestions?

  19. Avatar herbertskurrie

    Greetings I am so happy I found your blog page, I really found you by error,
    while I was looking on Bing for something else, Regardless I am here now and would just like to say
    kudos for a tremendous post and a all round enjoyable blog
    (I also love the theme/design), I don’t have time to go through it all
    at the moment but I have saved it and also added your RSS
    feeds, so when I have time I will be back to read a great deal more, Please do keep up the
    superb b.

  20. I really like what you guys tend to be up too. This sort of clever work and reporting!
    Keep up the very good works guys I’ve included you
    guys to blogroll.

  21. Its like you read my mind! You appear to know a lot about this, like you wrote the
    book in it or something. I think that you could do with a
    few pics to drive the message home a little bit, but other than that, this is wonderful blog.

    An excellent read. I will certainly be back.

  22. Hey there would you mind sharing which blog platform you’re using?
    I’m looking to start my own blog soon but I’m having a tough time making a
    decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design and style seems different then most blogs
    and I’m looking for something unique.
    P.S Sorry for being off-topic but I had to ask!

  23. Hi there! I simply wish to offer you a big thumbs up for your excellent information you’ve got right here on this post.

    I’ll be coming back to your blog for more soon.

  24. Avatar http://tinyurl.com

    Generally I do not learn post on blogs, but I wish to
    say that this write-up very pressured me to try and do
    so! Your writing style has been amazed me. Thank you, quite great
    article.

  25. Avatar លុយដុល្លារក្លែងក្លាយលក់នៅសៀមរាប

    Good day! I could have sworn I’ve been to this site before but after browsing through some of
    the post I realized it’s new to me. Anyhow, I’m definitely glad I found it and I’ll be bookmarking and checking back frequently!

  26. Hi there, constantly i used to check website posts here in the early hours in the break of day, because i like to find out more and more.

  27. I think the admin of this site is actually working hard in support of his web site, because here every data is quality based material.

  28. great issues altogether, you simply received a new reader.What may you recommend in regards to your postthat you simply made some days ago? Any positive?

  29. Really enjoyed this post.Really thank you! Keep writing

  30. Really enjoyed this post.Really thank you! Keep writing. makaberzux

  31. Really enjoyed this post.Really thank you! Keep writing

  32. I loved your blog.Thanks Again. Great.

  33. Really enjoyed this post.Really thank you! Keep writing

  34. Really enjoyed this post.Really thank you! Keep writing

  35. Really enjoyed this post.Really thank you! Keep writing

  36. thanks man

  37. Hi to every body, it’s my first go to see of this webpage; this weblog includes awesome and genuinely excellent stuff in support of readers.

Leave a Comment

Your email address will not be published. Required fields are marked *