{"record":{"id":"d028331096f6aea0","repo":"microsoft/aspire","slug":"bind-mounts-are-not-supported-by-the-kubernetes-publisher","errorCode":null,"errorMessage":"Bind mounts are not supported by the Kubernetes publisher","messagePattern":"Bind mounts are not supported by the Kubernetes publisher","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Kubernetes/KubernetesResource.cs","lineNumber":310,"sourceCode":"    }\n\n    private void ProcessVolumes()\n    {\n        if (!resource.TryGetContainerMounts(out var mounts))\n        {\n            return;\n        }\n\n        foreach (var volume in mounts)\n        {\n            if (volume.Source is null || volume.Target is null)\n            {\n                throw new InvalidOperationException(\"Volume source and target must be set\");\n            }\n\n            if (volume.Type == ContainerMountType.BindMount)\n            {\n                throw new InvalidOperationException(\"Bind mounts are not supported by the Kubernetes publisher\");\n            }\n\n            var newVolume = new VolumeMountV1\n            {\n                Name = volume.Source,\n                ReadOnly = volume.IsReadOnly,\n                MountPath = volume.Target,\n            };\n\n            Volumes.Add(newVolume);\n        }\n    }\n\n#pragma warning disable ASPIREPROBES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.\n    private void ProcessProbes()\n    {\n        if (!resource.TryGetAnnotationsOfType<ProbeAnnotation>(out var probeAnnotations))\n        {","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Kubernetes/KubernetesResource.cs#L292-L328","documentation":"Thrown by ProcessVolumes in KubernetesResource when a container mount has type BindMount. Bind mounts reference host filesystem paths, which do not translate to Kubernetes manifests; the publisher only supports named volumes mounted via VolumeMountV1.","triggerScenarios":"Calling WithVolume(sourceHostPath, targetPath) or any API that creates a ContainerMountType.BindMount on a resource, then publishing with the Kubernetes publisher.","commonSituations":"Local dev workflows that bind-mount host directories (e.g. './data:/data') and are then published to Kubernetes without switching to named volumes or PVCs.","solutions":["Replace the bind mount with a named volume via WithVolume(volumeName, targetPath)","Use a Kubernetes persistent volume/claim through a resource customization annotation if persistent storage is required","Guard the mount with a runtime-vs-publish check so bind mounts only apply during F5/run mode"],"exampleFix":"// before\nvar db = builder.AddPostgres(\"db\").WithDataBinding(\"./pgdata\");\n// after\nvar db = builder.AddPostgres(\"db\").WithDataVolume();","handlingStrategy":"validation","validationCode":"if (mount.Type == ContainerMountType.BindMount) throw new InvalidOperationException(\"Replace bind mounts with named volumes for Kubernetes publishing\");","typeGuard":null,"tryCatchPattern":"try { PublishAsync(...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Bind mounts are not supported\")) { /* convert to named volume */ }","preventionTips":["Use WithDataVolume()/named volumes instead of host paths","Gate bind mounts behind run-mode-only code paths","Add a publish-mode integration test that enumerates mounts"],"tags":["kubernetes","volumes","bind-mount","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}