docker image id / digests / tags

26/09/2020

building

returns an imageId

docker build 
Successfully built d4a6

the .Id changes only if a new image is built. If nothing was really built the id doesn't change.

inspecting

get an image Id and a digest.

The digest is only generated when the image is pushed to a registry

docker images --digests --format '{{ json . }}' registry.raphaelpiccolo.com/flatbay

docker image inspect registry.raphaelpiccolo.com/flatbay
# Id: [0].Id
# digest: [0].RepoDigests[0]

docker image inspect --format '{{ .Id }}' registry.raphaelpiccolo.com/flatbay

pushing the image

will echo the digest

docker push

try inspecting to see the digest.

check from a private registry

curl -v -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' https://registry.raphaelpiccolo.com/v2/flatbay/manifests/latest

on obtient le imageId en header :

docker-content-digest: sha256:3b9a13

le digest est dans le json : config.digest

check from dockerhub

on recupere un token

curl -s https://auth.docker.io/token?service=registry.docker.io&scope=repository:${repo}:pull

on utilise ce token pour obtenir les infos

curl -v \
     -H "Accept: application/vnd.docker.distribution.manifest.list.v2+json" \
     -H "Authorization: Bearer $token" \
     -I -s "https://registry-1.docker.io/v2/${repo}/manifests/${tag}"

le digest est la

docker-content-digest: sha256:3b9a13

tags

quand je build une nouvelle image est créée avec un nouvel id.
l'anciene image perd son tag latest et devient "<none>"
si je pull ça remet le tag sur l'ancienne image.
si je build ça remet le tag sur la nouvelle image.