Use image hash instead of tag in pod definition

4/16/2019

I am troubleshooting some errors on one of my cronjobs and I would like to make sure that the right image is being used by the pods. Is it possible to specify the image using the hash instead of the repo/name:tag syntax?

-- ITChap
kubernetes

2 Answers

4/16/2019

From the documentation:

The image property of a container supports the same syntax as the docker command does, including private registries and tags.

Which means it allows you to pull a hash based on the docker syntax for pulling a hash:

docker pull $DOCKER_REGISTRY/$NAMESPACE/$APP_NAME:$SHA1
-- Blokje5
Source: StackOverflow

4/16/2019

As Docker is (in most cases) the one responsible of image fetching, you can do as stated in their documentation - <repo>/<name>@sha256:<sha256>.

For example, if we'd like to use the image of Ubuntu with the SHA256 digest of 45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2, it would look something like ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2

-- yanivoliver
Source: StackOverflow