4

I want to run a docker watchtower to automatically upgrade my docker containers whenever I push a new version to my private registry.

However, watchtower doesn't find containers in my private registry.

Does anyone know how to run watchtower with a private docker registry?

Gama11
  • 31,714
  • 9
  • 78
  • 100
Benjamin Scharbau
  • 2,028
  • 1
  • 16
  • 33

2 Answers2

8

Watchtower maintainer and developer here. We actually do have support for using private registries. This is done by using a fully qualified name as the image name, ie. example.com/my-org/my-image:my-tag, as well as mounting config.json at the watchtower container root.

See the docs, specifically https://containrrr.github.io/watchtower/usage-overview/

The docs could probably be clearer, and if you feel up for the task, feel free to improve them once you get it working.

Thanks, Simon

simme
  • 1,514
  • 12
  • 23
0

Update: While this approach still is likely to work, there is native support for this in watchtower.


Watchtower currently only supports the Docker Hub private registry, not off-site registries like Quay or Gitlab.

An alternative might be to use something like webhook and include a HTTP request to an endpoint from whatever CI/CD platform you're using.

That way, instead of checking for updates, you can ping the endpoint whenever a change is made, and auto-update. It's push rather than pull, but it can achieve a similar effect.

An example script for something like running a web server might be:

#!/bin/bash
docker pull [your-registry][repo]:latest
docker stop [repo-name]
docker rm [repo-name]
docker run -d --name [repo-name] -p 80:4000 --restart always [your-registry][repo]:latest

It's not the slickest deployment method. You're probably better to use a dedicated CI/CD provider in production that can better orchestrate the build, testing and deployment pipeline. But it's a quick and dirty way to spawn a staging server.

simme
  • 1,514
  • 12
  • 23
Lee Benson
  • 11,185
  • 6
  • 43
  • 57
  • Sorry if I came across as confrontative, I'll just go ahead and edit your answer instead. – simme Aug 23 '20 at 13:27
  • Not at all. Just making it clear that things change over time, and an answer today might not be relevant four years from now. Community edits are a better way to prevent drift. – Lee Benson Aug 23 '20 at 17:15