Skip to content

Conversation

ctalledo
Copy link
Contributor

@ctalledo ctalledo commented Jun 10, 2025

- What I did

Prior to this change, docker image load and docker image save accept only a single platform via the --platform option.

This change adds support for multiple platforms using a comma-separated list passed to --platform. E.g.:

docker image save --platform linux/amd64,linux/arm64/v8 -o b.tar busybox:latest
docker image load --platform linux/amd64,linux/arm64/v8 -i b.tar

** NOTE **: Depends on the corresponding change in the Moby engine (see moby/moby#50166).

- How I did it

Updated the --platform option in the image load and image save commands to accept an array of platforms, as opposed to a single platform.

- How to verify it

Run updated unit tests.

- Human readable description for the release notes

`docker image load` and `docker image save` now supports multiple platform selection via `--platform` flag (e.g., `docker image load --platform linux/amd64,linux/arm64 -i image.tar`).

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

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.05%. Comparing base (8b8f558) to head (0ba4362).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6126      +/-   ##
==========================================
+ Coverage   55.02%   55.05%   +0.03%     
==========================================
  Files         361      361              
  Lines       30152    30161       +9     
==========================================
+ Hits        16591    16605      +14     
+ Misses      12604    12598       -6     
- Partials      957      958       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ctalledo ctalledo force-pushed the fix-for-moby-48759 branch from 54b967e to 8993f54 Compare June 10, 2025 23:34
name: "with-comma-separated-platforms",
args: []string{"--platform", "linux/amd64,linux/arm64/v8,linux/riscv64"},
imageLoadFunc: func(input io.Reader, options ...client.ImageLoadOption) (image.LoadResponse, error) {
assert.Check(t, len(options) > 0) // can be 1 or two depending on whether a terminal is attached :/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm I'm not sure I understand this one. How does terminal affect parsing here?

Copy link
Contributor Author

@ctalledo ctalledo Jul 23, 2025

Choose a reason for hiding this comment

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

I was simply copying a comment in the test right above this line (i.e., "with-single-platform"), but the underlying rationale for the comment comes from this code:

func runLoad(ctx context.Context, dockerCli command.Cli, opts loadOptions) error {
...
	var options []client.ImageLoadOption
	if opts.quiet || !dockerCli.Out().IsTerminal() {
		options = append(options, client.ImageLoadWithQuiet(true))
	}
...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah right.. We should apply these opts to a temporary var and then check the resulting opts struct, but we can't do that because these types are unexported..

I guess the only way to test it in this situation is by checking HTTP request at the HTTP client, but that would need rewriting the test a bit.

Although, I think the best solution would be to have a debug helper on the client side that would allow introspecting for testing purposes...

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should do that in a follow up though

@thaJeztah
Copy link
Member

FWIW; I had a "wip" branch to implement a multi-platform option, but it still needs some work (and a decision where we want to put it);

@vvoland
Copy link
Collaborator

vvoland commented Jul 23, 2025

Changed the changelog a bit, let me know if that looks good.

cc @ArthurFlag

@ctalledo
Copy link
Contributor Author

Changed the changelog a bit, let me know if that looks good.

Thanks @vvoland, LGTM.

@vvoland vvoland merged commit 1ca6c94 into docker:master Jul 24, 2025
101 of 102 checks passed
@ctalledo ctalledo deleted the fix-for-moby-48759 branch July 24, 2025 18:07
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.

5 participants