diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 207686c05c..19a5338791 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -738,7 +738,12 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { UnsetLabels: query.UnsetLabels, } - for _, platformSpec := range query.Platform { + platforms := query.Platform + if len(platforms) == 1 { + // Docker API uses comma sperated platform arg so match this here + platforms = strings.Split(query.Platform[0], ",") + } + for _, platformSpec := range platforms { os, arch, variant, err := parse.Platform(platformSpec) if err != nil { utils.BadRequest(w, "platform", platformSpec, err) diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index 63284b49cf..c592eec228 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -667,6 +667,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // default: // description: | // Platform format os[/arch[/variant]] + // Can be comma separated list for multi arch builds. // (As of version 1.xx) // - in: query // name: target diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at index cfed2dc411..8cd7ed2234 100644 --- a/test/apiv2/10-images.at +++ b/test/apiv2/10-images.at @@ -274,6 +274,12 @@ else _show_ok 1 "compat quiet build" fi +# Do not try a real build here to tests the comma separated syntax as emulation +# is slow and may not work everywhere, checking the error is good enough to know +# we parsed it correctly on the server I would say +t POST "/build?q=1&dockerfile=containerfile&platform=linux/amd64,test" $CONTAINERFILE_WITH_ERR_TAR 400 \ + .message="failed to parse query parameter 'platform': \"test\": invalid platform syntax for --platform=\"test\": \"test\": unknown operating system or architecture: invalid argument" + cleanBuildTest # compat API vs libpod API event differences: