Kubernetes: list available container images

Question: how can I list available container images?

I’m working with Kubernetes. My test container is just Nginx. I deployed image version 1.14.1, but I’m sure it’s an old version. How can I programmatically tell which versions of Nginx are available?

Once I have a another version, I can do an in-place update with “kubectl set image deploy/mydeploy nginx=nginx:1.16.0 –record=true”, but I have to find the version first 🙂

Answer #1: I don’t know! Does Kubernetes have a “list images in repos” command I’ve missed?

Answer #2: If I’m a human using Docker, I can use the DockerHub page https://hub.docker.com/_/nginx

Answer #3: programmatically, here’s how to do it in Docker.

Oddly there’s no command for this, but there _is_ a simple API we can abuse to get what we want:

wget -q https://registry.hub.docker.com/v1/repositories/nginx/tags -O - | jq -r '.[].name'
1.13.9-perl
1.14
1.14-alpine
1.14-alpine-perl
1.14-perl
1.14.0

.

To get the latest semver version, use GNU Sort, and double-check the “version-sort” option:

wget -q https://registry.hub.docker.com/v1/repositories/nginx/tags -O - | jq -r '.[].name' | gsort --reverse --version-sort | egrep '^[0-9]' | head -1

1.19.5-perl

Resources

Docker: list all tags in registry

https://stackoverflow.com/questions/28320134/how-can-i-list-all-tags-for-a-docker-image-on-a-remote-registry

Use GNU Sort for Semver

https://unix.stackexchange.com/a/350317/67276