TL;DR Using the python docker module, how can I get the version of an image?
When calling docker images the version is nicely broken out under the Tag column which would look somethin like. The following.
| REPOSITORY | TAG | IMAGE ID | CREATED | SIZE |
|---|---|---|---|---|
| python | latest | abc123abc123 | 1 year ago | 3.14MB |
What is the simplest way to get the version tag (e.g. latest) when using the python API? For example,
image = docker.from_env().images.list(filters = { 'reference' : 'python'})[0]
repo_tag = image.attrs['RepoTags']
print("repo_tag") # python:latest
version = repo_tag.split(":")[1]
Is there a more direct method instead of doing a .split?