Skip to content

docs: clarify that tag or digest in fromImage is ignored#49266

Merged
vvoland merged 1 commit intomoby:masterfrom
dvdksn:fromimage-tag-clarification
Jan 21, 2025
Merged

docs: clarify that tag or digest in fromImage is ignored#49266
vvoland merged 1 commit intomoby:masterfrom
dvdksn:fromimage-tag-clarification

Conversation

@dvdksn
Copy link
Copy Markdown
Contributor

@dvdksn dvdksn commented Jan 13, 2025

Signed-off-by: David Karlsson [email protected]

- What I did

Updated the description for the fromImage parameter on ImageCreate to clarify that if a tag/digest is provided in this field, it is ignored.

- How I did it

- How to verify it

- Description for the changelog

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

Copy link
Copy Markdown
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@thaJeztah
Copy link
Copy Markdown
Member

Don't merge yet; I think this is not correct (after some testing 😞)

Comment thread api/swagger.yaml Outdated
- name: "fromImage"
in: "query"
description: "Name of the image to pull. The name may include a tag or digest. This parameter may only be used when pulling an image. The pull is cancelled if the HTTP connection is closed."
description: "Name of the image to pull. If the name includes a tag or digest, it is ignored. Use the `tag` property to specify the desired tag or digest. This parameter may only be used when pulling an image. The pull is cancelled if the HTTP connection is closed."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah right, @thaJeztah is correct!

If a tag is provided here it will be used, but tag will take precedence if its provided.

So fromImage=ubuntu:latest&tag=noble would actually result in ubuntu:noble being considered

@thaJeztah
Copy link
Copy Markdown
Member

OK; looks like tag has priority, but not in all cases, and it looks like we have a bug on reporting a confusing error;

it ignored a ?tag= is provided, but if that's missing and the fromImage does contain a tag, it looks like we're accepting that tag as well.

I guess we tried to avoid accidentally pulling "all tags".

# pulls latest
curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn:latest'

# pulls "0.1.0" tag
curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn:0.1.0'

# tag query parameter takes precedence; pulls "0.1.0" tag
curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn:0.1&tag=0.1.0'

# no tag in "fromImage" AND no tag in "tag" parameter; pulls all tags
curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn'

For digests.. it looks like there's some inconsistency; specifying the digest in fromImage and no tag parameter provided, pulls by digest;

# pulls by digest
curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn@sha256:641f09e6a0409cc0a9f98e943dd033aa3b914d9141174c39bc0d00cb9519e07b'

# tag + digest in "fromImage"; tag resolution  is skipped and image is pulled by digest
curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn:0.1.0@sha256:641f09e6a0409cc0a9f98e943dd033aa3b914d9141174c39bc0d00cb9519e07b'

This seems inconsistent though; if fromImage contains a digest, the tag parameter is ignored, or at least, the digest takes precedence (but no "all-tags");

curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn@sha256:641f09e6a0409cc0a9f98e943dd033aa3b914d9141174c39bc0d00cb9519e07b&tag=0.1.0'
curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn:0.1@sha256:641f09e6a0409cc0a9f98e943dd033aa3b914d9141174c39bc0d00cb9519e07b&tag=0.1.0'

Passing a tag in fromImage and a valid digest in tag will pull by digest;

curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn:latest&tag=sha256:641f09e6a0409cc0a9f98e943dd033aa3b914d9141174c39bc0d00cb9519e07b'

Passing an incorrect digest through tag is a failure (here I passed a digest for busybox); that looks like a bug at least

curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn@sha256:641f09e6a0409cc0a9f98e943dd033aa3b914d9141174c39bc0d00cb9519e07b&tag=sha256:3A2919d0172f7524b2d8df9e50066a682669e6d170ac0f6a49676d54358fe970b5'
{"message":"invalid tag format"}

curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/images/create?fromImage=thajeztah/angry-unicorn:latest&tag=sha256:3A2919d0172f7524b2d8df9e50066a682669e6d170ac0f6a49676d54358fe970b5'
{"message":"invalid tag format"}

@thaJeztah thaJeztah modified the milestones: 28.0.0, 29.0.0 Jan 17, 2025
@dvdksn dvdksn force-pushed the fromimage-tag-clarification branch from f8bde2a to bf7a87a Compare January 20, 2025 08:55
@dvdksn
Copy link
Copy Markdown
Contributor Author

dvdksn commented Jan 20, 2025

@thaJeztah @vvoland I've updated to capture some of the nuance that exists here w.r.t. fromImage vs tag. PTAL 🙏🏻

Copy link
Copy Markdown
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, thanks!

@thaJeztah thaJeztah modified the milestones: 29.0.0, 28.0.0 Jan 20, 2025
@vvoland vvoland merged commit 96419cb into moby:master Jan 21, 2025
@dvdksn dvdksn deleted the fromimage-tag-clarification branch January 21, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants