cli: [Bug] Docker pull/push to the same registry changes image digest
Description
Docker pull/push to the same registry changes image digest pushed by another tool. looks like docker reformats manifest the way it like.
The bug breaks docker trust sign process as digest is already used in other systems.
Combined with session nature docker login makes it hurts any CI process badly, as only docker push can be used for consistent pushing\signing
Describe the results you expected: My understanding is that docker push\pull to the same repo have to leave docekr digest the same.
Steps to reproduce the issue:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
curl -L https://github.com/GoogleContainerTools/jib/releases/download/v0.8.0-cli/jib-jre-0.8.0.zip -o jib.zip && unzip jib.zip
./build.yaml
apiVersion: jib/v1alpha1
kind: BuildFile
from:
image: scratch
layers:
entries:
- name: scripts
files:
- properties:
filePermissions: 755
src: build.yaml
dest: /build.yaml
jib-0.8.0/bin/jib build -c `pwd` -b build.yaml -t registry://localhost:5000/test --allow-insecure-registries --image-metadata-out=meta.json
$ cat meta.json
{"image":"localhost:5000/test","imageId":"sha256:8a3b3ebf46ea72d4c4859e18147485204d7144e3e82dd5b6416b167af9f25a86","imageDigest":"sha256:40b9754190108932d81362bc2b845fb6176b20d5ac99312abf2a1f149309e39e","tags":["latest"]}
$ docker --version
Docker version 20.10.12, build e91ed57
$ docker pull localhost:5000/test
Using default tag: latest
latest: Pulling from test
cf51c3f692e5: Pull complete
Digest: sha256:40b9754190108932d81362bc2b845fb6176b20d5ac99312abf2a1f149309e39e
Status: Downloaded newer image for localhost:5000/test:latest
localhost:5000/test:latest
$ docker push localhost:5000/test
Using default tag: latest
The push refers to repository [localhost:5000/test]
77ef8d169f22: Layer already exists
latest: digest: sha256:340a8be0c6d5d9ec54e49f484a88a3a92290ad8ade703da654265cafa3c8e315 size: 52
The docker imageDigest is changed from: sha256:40b9754190108932d81362bc2b845fb6176b20d5ac99312abf2a1f149309e39e to: sha256:340a8be0c6d5d9ec54e49f484a88a3a92290ad8ade703da654265cafa3c8e315
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 5
- Comments: 23 (3 by maintainers)
This is still an issue. I don’t understand that this doesn’t bother more people. Even other CLIs have this problem like
crane, see https://github.com/google/go-containerregistry/issues/1922.Small clarification on that one: they can be pushed, it’s just that full image content is required locally (so you need to pull all the platform locally first), or in the remote registry repository (registry-dependent, but pushing to the same repository that the image was pulled from should still work).
@vvoland nonsense, if digest depends on manifest, it should not be touched. In other words implementation should not affect the contract. if implementation breaks contract its clear bug.
use the following,
crane cp <src> <dest>it will not change the image digest!
@thaJeztah “manifest that was pushed got reformatted (pretty-print), instead of preserving the original without whitespace” exactly and it is quite scary behaviour as image signing process is totally broke. Another potential consequence - broken compatibility if docker cli will change formatting.
@justincormack @tonistiigi what do you think?
Hmm… right, so it looks like the manifest that was pushed got reformatted (pretty-print), instead of preserving the original without whitespace (probably that was generated with a library to create canonical JSON, as described in the image-spec (ISTR that was largely abandoned at some point, as canonical JSON was still open to too many variations.
@justincormack @tonistiigi any ideas?