Take for example the following repository hosted on dockerhub:
https://hub.docker.com/r/frolvlad/alpine-miniconda3
The following command is executed to pull an image via digest:
docker pull frolvlad/alpine-miniconda3:python3.7@sha256:9bc9c096713a6e47ca1b4a0d354ea3f2a1f67669c9a2456352d28481a6ce2fbe
Based off of the docker documentation pulling an image via digest has the following property:
Using this feature “pins” an image to a specific version in time
From what I understand, the docker image pulled with that digest at any point is immutable.
Though it doesn't comment on the mutable, or seemingly mutable references within.
Most importantly the first line of the docker file reads
FROM frolvlad/alpine-glibc:alpine-3.9
I would assume based off my readings if the author changes this first line in the dockerfile and pushes (even if it is the same tag), I would not be impacted as I am pointing to the image digest. However,
due to the fact that the author referenced a tag in the dockerfile, and not a digest, how can I confirm what dockerfile/base image was used to build their image? As it would seem just analyzing the frolvlad/alpine-glibc:alpine-3.9 dockerfile would not be sufficient as it could have been different at the time of the image creation.
You're correct that an image pulled by digest is effectively (!) unchangeable.
The image digest is a SHA-256 hash computed from the layers that constitute the image. As a result it's highly improbable that a different image would share the same digest.
Once created an image's layers don't change. So even if the
FROMimage were changed, your existing images would not be changed by it.However, if you rebuilt your images using the new (same-tagged)
FROMimage, your image's digest would change and this would be a signal to you that's something has changed.It is possible (and a good practice) to use digests in
FROMstatements too (for the reasons you cite) but few developers do this. You may wish to ensure yourDockerfilesuse digests inFROMstatements to ensure you're always using the same image sources.However, it's turtles all the way down (or up) though and so you are recursively delegating trust to images from which yours are derived all the way up to
SCRATCH.This is one reason why image vulnerability tools are recommended.
I explored this for my own education recently:
https://medium.com/google-cloud/adventures-w-docker-manifests-78f255d662ff