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
Enjoying the docker and please do write on Kafka will be helpful.
Sure, will do!
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!
Thanks!
I have read so many articles or reviews about the blogger lovers
however this paragraph is in fact a fastidious post, keep it up.
Thanks!
This is a topic which is near to my heart…
Thank you! Exactly where are your contact details though?
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!
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.
Very neat blog.Much thanks again. Really Great.
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.
Hello, its nice paragraph concerning media print, we
all be aware of media is a great source of facts.
It’s nearly impossible to find well-informed people for this subject, however, you seem like you know what you’re talking about! Thanks
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!
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!
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!
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!
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!
Im grateful for the blog post.Much thanks again. Will read on…
Thanks in favor of sharing such a fastidious idea, post
is pleasant, thats why i have read it fully
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?
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.
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.
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.
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!
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.
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.
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!
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.
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.
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?
Really enjoyed this post.Really thank you! Keep writing
Really enjoyed this post.Really thank you! Keep writing. makaberzux
Really enjoyed this post.Really thank you! Keep writing
I loved your blog.Thanks Again. Great.
Really enjoyed this post.Really thank you! Keep writing
Really enjoyed this post.Really thank you! Keep writing
Really enjoyed this post.Really thank you! Keep writing
thanks man
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.