How is it possible to get latest creation date of Docker image that exists at registry? Recently we have a problem that Docker image was not automatically pulled at some of our cluster slave servers and the project was running at the very outdated container environment. So am expecting to run a cron-script once per day to check that pulled Docker image is not 24 hours older than registry Docker image.
The simplest way I know of is to write a simple script that uses the Docker Registry REST API and does basic manipulation of the results for your needs.
Here's some example code in Python 3 that would do this for a repo I work with:
import requests
repo_tag_url = 'https://hub.docker.com/v2/repositories/streamsets/datacollector/tags'
results = requests.get(repo_tag_url).json()['results']
for repo in results:
print(repo['name'], repo['last_updated'])
Which, for my example, returns:
3.0.0.0-SNAPSHOT 2017-10-23T14:43:29.888877Z
latest 2017-10-05T23:05:03.636155Z
2.7.2.0 2017-10-05T22:50:53.269831Z
2.7.2.0-RC5 2017-10-05T19:34:19.523402Z
2.7.2.0-RC4 2017-10-05T02:05:52.522323Z
2.7.2.0-RC3 2017-10-04T00:08:02.929502Z
2.8.0.0-SNAPSHOT 2017-10-03T21:55:08.042479Z
2.7.2.0-RC2 2017-10-03T19:20:56.642686Z
2.7.2.0-RC21 2017-09-30T21:42:27.924190Z
2.7.2.0-RC1 2017-09-30T17:34:14.409320Z
Something like Docker history?
From the doc:
Description: Show the history of an image
Usage: docker history [OPTIONS] IMAGE
For example:
$ docker history imageName
And using the --format option:
$ docker images --format "{{.ID}}: {{.Created}} ago"
cc1b61406712: 2 weeks ago
<missing>: 2 weeks ago
<missing>: 2 weeks ago
<missing>: 2 weeks ago
<missing>: 2 weeks ago
<missing>: 3 weeks ago
<missing>: 3 weeks ago
<missing>: 3 weeks ago
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With