Skip to content

fix: docker pull with platform checks wrong image tag#45561

Merged
neersighted merged 1 commit intomoby:masterfrom
laurazard:fix-pull-platform
May 18, 2023
Merged

fix: docker pull with platform checks wrong image tag#45561
neersighted merged 1 commit intomoby:masterfrom
laurazard:fix-pull-platform

Conversation

@laurazard
Copy link
Member

@laurazard laurazard commented May 18, 2023

- Related

- What I did

Fix a bug where, if a user pulls an image with a tag != latest and a specific platform, we return an NotFound error for the wrong (latest) tag. see: #45558

This bug was introduced in 779a5b3 in the changes to daemon/images/image_pull.go, when we started returning the error from the call to GetImage after the pull.

We started doing this call – in 424c0eb – if pulling with a specified platform, to check if the platform of the pulled image matches the requested platform (for cases with single-arch images). However, when we call GetImage we're not passing the image tag, only name, so GetImage assumes latest which breaks when the user has requested a different tag.

- How I did it

- How to verify it

  • docker pull --platform amd64 quay.io/ansible/docker-test-containers:hello-world

- Description for the changelog

fix error when pulling an image for a specific platform when tag != "latest"

- A picture of a cute animal (not mandatory but encouraged)

image

This fixes a bug where, if a user pulls an image with a tag != `latest` and
a specific platform, we return an NotFound error for the wrong (`latest`) tag.
see: moby#45558

This bug was introduced in moby@779a5b3
in the changes to `daemon/images/image_pull.go`, when we started returning the error from the call to
`GetImage` after the pull. We do this call, if pulling with a specified platform, to check if the platform
of the pulled image matches the requested platform (for cases with single-arch images).
However, when we call `GetImage` we're not passing the image tag, only name, so `GetImage` assumes `latest`
which breaks when the user has requested a different tag, since there might not be such an image in the store.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@laurazard
Copy link
Member Author

Failure looks unrelated: https://github.com/moby/moby/actions/runs/5013915789/jobs/8987581073?pr=45561

 === FAIL: github.com/docker/docker/pkg/plugins TestClientWithRequestTimeout (0.01s)
    client_test.go:254: assertion failed: expected an error, got nil: expected error

@laurazard laurazard added the area/images Image Distribution label May 18, 2023
@neersighted neersighted merged commit b42c65d into moby:master May 18, 2023
@felixfontein
Copy link

Thanks @laurazard and everyone else involved for getting this fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

6 participants