Docker Compose – automated updates

Using docker-compose makes updating images and containers very easy – a simple command downloads any new images:

docker-compose pull

And another stops, updates and restarts containers:

docker-compose up -d

But what if you want to know about updates, without actually doing them – for example, to do a daily check but only update during non-critical times or when you’re around to fix any issues?

Unfortunately, neither docker or docker-compose seem to provide a way of reporting out-of-date images – but a simple pair of commands can do something similar.

docker-compose pull -q
docker images | fgrep '<none>'

This pulls any new images, quietly without reporting anything, and then looks for any images not associated with a tag – since the new images will now have the “latest” tag, the older ones show up.

After the update (docker-compose up -d) you should also delete the old images:

docker image prune -f

Probably there’s a better way to do this, but it works fine on my media centre to tell me of updates while still having control over when they are applied.