dotnet / docker-tools

This is a repo to house some common tools for our various docker repos.
MIT License
106 stars 43 forks source link

Use of `library` repo in base image name results in digest diff #1363

Open mthalman opened 1 month ago

mthalman commented 1 month ago

From the buildtools-prereqs repo, run this command: .\build.ps1 -DockerfilePath "*almalinux/8/source-build/amd64*". It results in the following exception:

Unhandled exception: System.InvalidOperationException: Found published digest 'sha256:e87da8566de5f0a10e0e6acdb7ca43da4ef97a114130691d7dd737d6923c863d' for tag 'library/almalinux:8' but could not find a matching digest value from the set of locally pulled digests for this tag: almalinux@sha256:e87da8566de5f0a10e0e6acdb7ca43da4ef97a114130691d7dd737d6923c863d. This most likely means that this tag has been updated since it was last pulled.
   at Microsoft.DotNet.ImageBuilder.ManifestServiceExtensions.GetImageDigestAsync(IInnerManifestService manifestService, String image, Boolean isDryRun) in /image-builder/src/ManifestServiceExtensions.cs:line 58

This happens because of the use of the library repo in the Dockerfile's base image name which was done in order to work around https://github.com/dotnet/docker-tools/issues/1341. The logic in Image Builder uses that image name to get the digest of the locally pulled image, but the output of that command has library/ stripped from the name:

-- EXECUTING: docker inspect library/almalinux:8 -f "{{ index .RepoDigests }}"
[almalinux@sha256:e87da8566de5f0a10e0e6acdb7ca43da4ef97a114130691d7dd737d6923c863d]

This leads to a diff with the expected digest (e.g. library/almalinux@sha256:e87da8566de5f0a10e0e6acdb7ca43da4ef97a114130691d7dd737d6923c863d), resulting in the exception being thrown.

dotnet-issue-labeler[bot] commented 1 month ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-issue-labeler[bot] commented 1 month ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.