{"record":{"id":"5789e31c42bf2885","repo":"microsoft/aspire","slug":"the-rust-app-resource-name-targets-target-which-cannot-be","errorCode":null,"errorMessage":"The Rust app '{resource.Name}' targets '{target}', which cannot be mapped to a supported Docker Linux container platform. Generated Rust containers support native Linux x86_64, aarch64, 32-bit ARM, and 32-bit x86 targets. Use an authored Dockerfile to publish this target.","messagePattern":"The Rust app '(.+?)' targets '(.+?)', which cannot be mapped to a supported Docker Linux container platform\\. Generated Rust containers support native Linux x86_64, aarch64, 32-bit ARM, and 32-bit x86 targets\\. Use an authored Dockerfile to publish this target\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Rust/RustHostingExtensions.cs","lineNumber":872,"sourceCode":"        RustAppResource resource,\n        ContainerResource container)\n    {\n        var target = resource.TryGetLastAnnotation<RustCargoOptionsAnnotation>(out var options)\n            ? options.Target\n            : null;\n\n        if (target is null)\n        {\n            return null;\n        }\n\n        // Built-in Rust Linux targets use <architecture>-<vendor>-linux-<environment>, for example\n        // armv7-unknown-linux-musleabihf. Custom target JSON paths and non-Linux targets do not carry enough\n        // information to choose a native Docker platform and therefore need an authored Dockerfile.\n        var targetParts = target.Split('-');\n        if (targetParts.Length < 4 || !string.Equals(targetParts[2], \"linux\", StringComparison.Ordinal))\n        {\n            throw CreateUnsupportedContainerTargetException(resource, target);\n        }\n\n        var architecture = targetParts[0];\n        // ContainerTargetPlatform.LinuxArm emits Docker's canonical linux/arm platform, which containerd\n        // normalizes to the v7 variant. See https://github.com/containerd/platforms/blob/main/platforms.go.\n        var platform = architecture switch\n        {\n            \"x86_64\" => ContainerTargetPlatform.LinuxAmd64,\n            \"aarch64\" => ContainerTargetPlatform.LinuxArm64,\n            \"i386\" or \"i486\" or \"i586\" or \"i686\" => ContainerTargetPlatform.Linux386,\n            \"arm\" or \"armv4t\" or \"armv5te\" or \"armv7\" or \"thumbv7neon\" => ContainerTargetPlatform.LinuxArm,\n            _ => throw CreateUnsupportedContainerTargetException(resource, target)\n        };\n\n        var targetEnvironment = targetParts[3];\n        // The official Rust image index used by the default build stage publishes amd64 and arm64 images,\n        // but not Docker's 32-bit arm or 386 platforms. Those architectures therefore need a custom build\n        // image even when the default Alpine runtime image already supports the target platform.","sourceCodeStart":854,"sourceCodeEnd":890,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Rust/RustHostingExtensions.cs#L854-L890","documentation":"During publish, Aspire maps a Rust target triple to a Docker Linux container platform. If the target triple does not have the <arch>-<vendor>-linux-<env> shape (custom target JSON files or non-Linux targets), the model cannot pick a native Docker platform and publishing fails, telling you to supply an authored Dockerfile instead.","triggerScenarios":"Setting a RustAppHost's target to a custom target triple path (e.g. path to a .json target spec) or a non-Linux triple (e.g. x86_64-pc-windows-msvc) and running publish/dockerfile generation.","commonSituations":"Using an embedded/bare-metal target, a macOS/Windows target, or a project-specific custom target JSON file that Aspire cannot parse into architecture-vendor-linux-environment parts.","solutions":["Switch to a supported standard Linux target triple (x86_64-unknown-linux-musl, aarch64-unknown-linux-musl, etc.)","Author your own Dockerfile and point the resource at it instead of relying on generated Dockerfile output","If a custom target is required, keep it out of the container resource target and build via a custom Dockerfile"],"exampleFix":"// before\nbuilder.AddRustApp(\"app\", \"./app\").WithTargetTriple(\"x86_64-pc-windows-msvc\");\n// after\nbuilder.AddRustApp(\"app\", \"./app\").WithTargetTriple(\"x86_64-unknown-linux-musl\");","handlingStrategy":"validation","validationCode":"var isStandardLinuxTriple = target.Split('-') is { Length: >= 4 } p && p[2] == \"linux\";\nif (!isStandardLinuxTriple) throw new InvalidOperationException($\"{target} requires an authored Dockerfile\");","typeGuard":null,"tryCatchPattern":"try { appHost.PublishDockerfile(...); } catch (UnsupportedContainerTargetException ex) { /* fall back to an authored Dockerfile */ }","preventionTips":["Use only standard Rust Linux target triples for container resources","Keep a custom Dockerfile ready when using custom target JSON specs","Validate the target triple format before publish"],"tags":["rust","containers","docker","publish","platform"],"backgroundTag":"unsupported-platform","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}