Tracking Docker Hub tags


Several times during the past weeks I've found myself in need of a particular tag for a Docker image on the Docker Hub. Upstream released their software and I wanted to deploy the container with the latest version. Of course you can keep reloading the Tags page to see if something new has shown up.

So I wrote a little tool called docker-tags. It keeps track of images you want to follow and when asked reports either:

  • the latest tag, layer and symbolic name
  • full report of all new tags since it last synced with the Hub

It can do this for either an image you specify by name, like jasperla/docker-yumrepo, or for all images it knows about.

Since the output is pure JSON it can be re-used as input for any other tool; for example to send a notification of any type. Hmm, seems like I've just come up with a project for another rainy day.

Demo

First we have to initialize the database. By default $PWD/docker-tags.db will be used, but this can be adjusted with the --db /path/to/db argument:

docker-tags initdb

Let's follow the busybox image:

docker-tags follow busybox

So far, nothing special going on yet.

Now, let's see what the latest tags are:

docker-tags latest busybox

Which returns a nice JSON hash:

{
  "busybox": {
    "image": "busybox",
    "layer": "964092b7",
    "tag": [
      "1",
      "1-uclibc",
      "1.24",
      "1.24-uclibc",
      "1.24.1",
      "1.24.1-uclibc",
      "uclibc"
    ]
  }
}

As you can see, the latest tag has many symbolic names, all referring to the same layer 964092b7.

If we now run report nothing will be printed, as there is nothing new to report:

$ docker-tags report
{
}
$

When a new latest is pushed to the busybox image, report will show the names and associated layer.

Conclusion

Since it's published on RubyGems, it can be installed simply with:

gem install docker-tags

Please let me know of any issues or missing features you're running into and report them on GitHub.