Description
#48295 introduced --platform flags on docker image save and docker image load, but the client currently only accepts a single one. From #48718 (comment)
One thing I just realized is that we don't allow multiple platforms to be specified. Currently, specifying multiple platforms will result in the last one to be used;
$ docker image load --platform=linux/arm64/v8 --platform=linux/riscv64 -i ./alpine2.tar
Loaded image: alpine:latest
$ docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE IN USE
alpine:latest beefdbd8a1da 10.6MB 3.37MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/arm64/v8 9cee2b382fe2 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 10.6MB 3.37MB
└─ linux/s390x 2b5b26e09ca2 0B 0B
Part of that would be the CLI, which discards multiple values if only 1 is supported; the above produces (URL-decoded);
/v1.48/images/load?platform={"architecture":"arm64","os":"linux","variant":"v8"}&quiet=0
I wonder what it would take to allow multiple platforms? My use-case here would be that I have a image.tar that contains (say) 8 platforms, but I only need 2 (e.g., only need arm64 and amd64). In that case, I'd want to be able to load only those.
Do we need API changes to make that possible, or would the API already be ablee to handle multiple? :thinking_face: We didn't ship this feature yet, so there's still time to adjust the API (even if we don't support multiple yet, the API coud be able to handle it, just produce an error when multiple are passed).
We can support multiple platforms with the current API via multiple platform query fields, like:
localhost/images/load?platform={"architecture":"arm64","os":"linux","variant":"v8"}&platform={"architecture":"arm","os":"linux","variant":"v5"}`
We must make changes before we release v28 so that the API and client at least are ready for this.
- Update
api/types/image.LoadOptions and api/types/image.SaveOptions to accept a []ocispec.Platform
- Update
Client.ImageLoad() and Client.ImageSave() to handle multiple platforms
- Change the CLI to accept multiple
--platform flags and/or a comma-separated list (--platform <platform>[,<platform>]) similar to how docker build allows this.
- Verify behavior on the daemon side
⚠️ if we cannot handle multiple platforms yet, it's OK to produce an error for now; the important bit is for the API (and Client) to be prepared.
Description
platformparameter to history, save and load #48295#48295 introduced
--platformflags ondocker image saveanddocker image load, but the client currently only accepts a single one. From #48718 (comment)We must make changes before we release v28 so that the API and client at least are ready for this.
api/types/image.LoadOptionsandapi/types/image.SaveOptionsto accept a[]ocispec.PlatformClient.ImageLoad()andClient.ImageSave()to handle multiple platforms--platformflags and/or a comma-separated list (--platform <platform>[,<platform>]) similar to howdocker buildallows this.