-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADD --checksum=sha512 uses sha256 algorithm to compare digest #2816
Comments
I originally asked about this on StackOverflow, thinking I was just doing something wrong, but someone else was able to reproduce the issue. They also supplied a workaround, in case anyone finds this and needs it. |
Looks like an issue in BuildKit or the Dockerfile frontend. Let me transfer this to the buildx repository, which is closer related, and handled by the team working on build |
@dvdksn Where does this originate? I don't think this is supported https://github.com/moby/buildkit/blob/v0.17.2/source/http/source.go#L407 and in the implementation PR I can see my comment explaining why other algorithms are not possible moby/buildkit#3093 (comment) |
@tonistiigi hmm looks like I added it in moby/buildkit#5237, but I can't recall what src I used to conjure that information up. I'll update it. |
It's confusing though, because sha256 works (as expected) #6 [2/3] ADD --checksum=sha256:f28da2f67cafc5186812966ea4a17ac54b57a9578070aec019e3e297d1aee532 https://get.docker.com out/install.sh
#6 DONE 0.0s
#7 [3/3] RUN ls -l /out
#7 0.254 total 24
#7 0.254 -rw------- 1 root root 22115 Nov 8 11:06 install.sh
#7 DONE 0.3s md5 fails with a somewhat useful error ( docker build --no-cache --progress=plain -<<'EOF'
FROM busybox
ADD --checksum=md5:6d94d4a82b6fee20c73acb7eb6f71613 https://get.docker.com out/install3.sh
RUN ls -l /out
EOF #3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s
Dockerfile:2
--------------------
1 | FROM busybox
2 | >>> ADD --checksum=md5:6d94d4a82b6fee20c73acb7eb6f71613 https://get.docker.com out/install3.sh
3 | RUN ls -l /out
4 |
--------------------
ERROR: failed to solve: unsupported digest algorithm But docker build --no-cache --progress=plain -<<'EOF'
FROM busybox
ADD --checksum=sha512:c6337ff13c9f58c2016cccf88ace46660b22ade0931b424b4a05d009770782894710e9c61aacd8cd76c53fcb9f5fe42b39c5b22d951acb566619372a47932d4c https://get.docker.com out/install2.sh
RUN ls -l /out
EOF #5 [2/3] ADD --checksum=sha512:c6337ff13c9f58c2016cccf88ace46660b22ade0931b424b4a05d009770782894710e9c61aacd8cd76c53fcb9f5fe42b39c5b22d951acb566619372a47932d4c https://get.docker.com out/install2.sh
#5 ERROR: digest mismatch sha256:f28da2f67cafc5186812966ea4a17ac54b57a9578070aec019e3e297d1aee532: sha512:c6337ff13c9f58c2016cccf88ace46660b22ade0931b424b4a05d009770782894710e9c61aacd8cd76c53fcb9f5fe42b39c5b22d951acb566619372a47932d4c
------
> [2/3] ADD --checksum=sha512:c6337ff13c9f58c2016cccf88ace46660b22ade0931b424b4a05d009770782894710e9c61aacd8cd76c53fcb9f5fe42b39c5b22d951acb566619372a47932d4c https://get.docker.com out/install2.sh:
------
ERROR: failed to solve: digest mismatch sha256:f28da2f67cafc5186812966ea4a17ac54b57a9578070aec019e3e297d1aee532: sha512:c6337ff13c9f58c2016cccf88ace46660b22ade0931b424b4a05d009770782894710e9c61aacd8cd76c53fcb9f5fe42b39c5b22d951acb566619372a47932d4c |
Thanks for looking into this folks! It's a bit disappointing to learn that only |
@tonistiigi do we have a tracking ticket for the error-handling (see my comment)? |
Description
When including a checksum in an
ADD
operation in a Dockerfile, the specified algorithm doesn't appear to be respected, despite the documentation stating that other checksum algorithms are supported.For example, if I have the following instruction in a Dockerfile:
and run
docker build .
in that Dockerfile's directory, I get this error:On the last line, note that it says:
but the
--checksum
argument in the dockerfile isSo docker doesn't appear to be respecting the specified checksum algorithm when specified in an
ADD
step.Reproduce
docker build .
Expected behavior
Docker should use the specified checksum algorithm (e.g. sha512) to validate the added file.
docker version
Client: Version: 27.3.1 API version: 1.47 Go version: go1.22.7 Git commit: ce12230 Built: Fri Sep 20 11:38:18 2024 OS/Arch: darwin/arm64 Context: desktop-linux Server: Docker Desktop 4.36.0 (175267) Engine: Version: 27.3.1 API version: 1.47 (minimum version 1.24) Go version: go1.22.7 Git commit: 41ca978 Built: Fri Sep 20 11:41:19 2024 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.7.21 GitCommit: 472731909fa34bd7bc9c087e4c27943f9835f111 runc: Version: 1.1.13 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Additional Info
Example dockerfile to reproduce the bug:
the checksum for the tarball can be validated here: https://www.ghostscript.com/releases/gsdnld.html
The text was updated successfully, but these errors were encountered: