{"record":{"id":"7ffde5898cf73b0b","repo":"docker/compose","slug":"service-q-build-configuration-does-not-support-pl","errorCode":null,"errorMessage":"service %q build configuration does not support platform: %s","messagePattern":"service %q build configuration does not support platform: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/options.go","lineNumber":76,"sourceCode":"func applyPlatforms(project *types.Project, buildForSinglePlatform bool) error {\n\tdefaultPlatform := project.Environment[\"DOCKER_DEFAULT_PLATFORM\"]\n\tfor name, service := range project.Services {\n\t\tif service.Build == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\t// default platform only applies if the service doesn't specify\n\t\tif defaultPlatform != \"\" && service.Platform == \"\" {\n\t\t\tif len(service.Build.Platforms) > 0 && !slices.Contains(service.Build.Platforms, defaultPlatform) {\n\t\t\t\treturn fmt.Errorf(\"service %q build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: %s\", name, defaultPlatform)\n\t\t\t}\n\t\t\tservice.Platform = defaultPlatform\n\t\t}\n\n\t\tif service.Platform != \"\" {\n\t\t\tif len(service.Build.Platforms) > 0 {\n\t\t\t\tif !slices.Contains(service.Build.Platforms, service.Platform) {\n\t\t\t\t\treturn fmt.Errorf(\"service %q build configuration does not support platform: %s\", name, service.Platform)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif buildForSinglePlatform || len(service.Build.Platforms) == 0 {\n\t\t\t\t// if we're building for a single platform, we want to build for the platform we'll use to run the image\n\t\t\t\t// similarly, if no build platforms were explicitly specified, it makes sense to build for the platform\n\t\t\t\t// the image is designed for rather than allowing the builder to infer the platform\n\t\t\t\tservice.Build.Platforms = []string{service.Platform}\n\t\t\t}\n\t\t}\n\n\t\t// services can specify that they should be built for multiple platforms, which can be used\n\t\t// with `docker compose build` to produce a multi-arch image\n\t\t// other cases, such as `up` and `run`, need a single architecture to actually run\n\t\t// if there is only a single platform present (which might have been inferred\n\t\t// from service.Platform above), it will be used, even if it requires emulation.\n\t\t// if there's more than one platform, then the list is cleared so that the builder\n\t\t// can decide.","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/options.go#L58-L94","documentation":"A service sets `platform:` to a value that is not in its build section's `platforms:` list. applyPlatforms validates every explicitly set service platform against the build platform list and errors out, because building would not produce an image runnable on the requested platform.","triggerScenarios":"Declaring `platform: linux/arm64` on a service whose build.platforms only contains linux/amd64; or setting platform via DOCKER_DEFAULT_PLATFORM after it passed the first check but then narrowing build.platforms so it no longer contains the resolved value.","commonSituations":"Copy-pasted compose files between amd64 and arm64 teams where one side edited build.platforms but not the platform key; multi-arch build matrices where a stale platform string (e.g. `linux/arm64/v8` vs `linux/arm64`) doesn't textually match the platforms entry.","solutions":["Make the strings match exactly: add the platform value to build.platforms (watch variant suffixes like /v8).","Or change/remove the service `platform:` key if any of the build platforms is fine.","Verify with `docker compose config` that the resolved platform matches one entry verbatim."],"exampleFix":"# before\nservices:\n  api:\n    platform: linux/arm64\n    build:\n      platforms: [linux/amd64, linux/arm64/v8]\n\n# after\nservices:\n  api:\n    platform: linux/arm64\n    build:\n      platforms: [linux/amd64, linux/arm64]","handlingStrategy":"validation","validationCode":"# bash: verify service platform is in build.platforms\nfor svcplat in $(docker compose config --format json | jq -r '.services | to_entries[] | select(.value.platform and .value.build.platforms) | \"\\(.key) \\(.value.platform) \\(.value.build.platforms | join(\",\"))\"'); do\n  set -- $svcplat; svc=$1; plat=$2; plats=$3\n  case \",$plats,\" in *\",$plat,\"*) ;; *) echo \"$svc: platform $plat not in [$plats]\" >&2; exit 2;; esac\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use identical platform strings (including /v8 variants) in platform and build.platforms.","Run `docker compose config` in CI to fail on invalid platform combos before deploy."],"tags":["platform","build","compose-file","validation"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}