{"record":{"id":"a69df8ef0b53d032","repo":"docker/cli","slug":"error-parsing-specified-platform-w","errorCode":null,"errorMessage":"error parsing specified platform: %w","messagePattern":"error parsing specified platform: %w","errorType":"validation","errorClass":"invalidParameterErr","httpStatus":null,"severity":"error","filePath":"cli/command/container/create.go","lineNumber":316,"sourceCode":"\t\t\t// Resolve this here for later, ensuring we error our before we create the container.\n\t\t\tcreds, err := readCredentials(dockerCLI)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"resolving credentials failed: %w\", err)\n\t\t\t}\n\t\t\tif len(creds) > 0 {\n\t\t\t\t// Set our special little location for the config file.\n\t\t\t\tcontainerCfg.Config.Env = append(containerCfg.Config.Env, \"DOCKER_CONFIG=\"+path.Dir(dockerConfigPathInContainer))\n\n\t\t\t\tapiSocketCreds = creds // inject these after container creation.\n\t\t\t}\n\t\t}\n\t}\n\n\tvar platform *ocispec.Platform\n\tif options.platform != \"\" {\n\t\tp, err := platforms.Parse(options.platform)\n\t\tif err != nil {\n\t\t\treturn \"\", invalidParameter(fmt.Errorf(\"error parsing specified platform: %w\", err))\n\t\t}\n\t\tplatform = &p\n\t}\n\n\tif options.pull == PullImageAlways {\n\t\tif err := pullImage(ctx, dockerCLI, config.Image, options); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\thostConfig.ConsoleSize[0], hostConfig.ConsoleSize[1] = dockerCLI.Out().GetTtySize()\n\n\tresponse, err := dockerCLI.Client().ContainerCreate(ctx, client.ContainerCreateOptions{\n\t\tName: options.name,\n\t\t// Image:            config.Image, // TODO(thaJeztah): pass image-ref separate\n\t\tPlatform:         platform,\n\t\tConfig:           config,\n\t\tHostConfig:       hostConfig,","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/create.go#L298-L334","documentation":"Returned by createContainer() when the --platform flag value cannot be parsed by platforms.Parse (cli/command/container/create.go:313-317). The error is marked invalidParameter so the CLI treats it as a client-side usage error. platforms.Parse expects an OCI-style 'os[/arch[/variant]]' string; missing components are allowed but malformed separators, unknown tokens, or empty segments fail.","triggerScenarios":"Passing --platform <value> to docker create/run with a value that platforms.Parse rejects: too many slash segments, empty segments ('linux//amd64'), or an otherwise malformed component. There is an earlier platforms.Parse at line 223 (without the invalidParameter wrap) used for a pre-check, but the canonical surfaced error is here.","commonSituations":"Typos like 'linux/amd64/extra', trailing/leading slashes, 'linux/', or pasting a full 'linux/amd64/v1' with an invalid variant. Also passing architecture-only values without an OS in contexts the parser rejects.","solutions":["Use the canonical 'os/arch[/variant]' form, e.g. --platform linux/amd64 or --platform linux/arm64/v8.","Remove trailing slashes and empty segments.","Verify the platform string with: docker run --rm --platform <value> alpine echo ok.","Check supported platforms for the image with docker manifest inspect <image>."],"exampleFix":"# before\ndocker create --platform linux/amd64/extra myimage   # too many segments\n# after\ndocker create --platform linux/amd64 myimage","handlingStrategy":"validation","validationCode":"// Validate a --platform string with the same parser the CLI uses.\nfunc validatePlatform(p string) error {\n    if p == \"\" { return nil }\n    if _, err := platforms.Parse(p); err != nil {\n        return fmt.Errorf(\"invalid --platform %q (expected os[/arch[/variant]]): %w\", p, err)\n    }\n    return nil\n}","typeGuard":"// isParsablePlatform reports whether p parses as os[/arch[/variant]].\nfunc isParsablePlatform(p string) bool {\n    _, err := platforms.Parse(p)\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Use canonical os/arch[/variant] strings: linux/amd64, linux/arm64/v8.","Avoid trailing slashes and empty segments.","Cross-check against docker manifest inspect <image> for supported platforms."],"tags":["container","platform","validation","oci"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}