{"record":{"id":"2a57de6ed012b6fc","repo":"containerd/containerd","slug":"failed-to-set-volume-mount-path-for-layer-s-w","errorCode":null,"errorMessage":"failed to set volume mount path for layer %s: %w","messagePattern":"failed to set volume mount path for layer (.+?): %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/mount/mount_windows.go","lineNumber":91,"sourceCode":"\t\t\t}\n\t\t}\n\t}()\n\n\tvolume, err := hcsshim.GetLayerMountPath(di, layerID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get volume path for layer %s: %w\", m.Source, err)\n\t}\n\n\tif len(parentLayerPaths) == 0 {\n\t\t// this is a base layer. It gets mounted without going through WCIFS. We need to mount the Files\n\t\t// folder, not the actual source, or the client may inadvertently remove metadata files.\n\t\tvolume = filepath.Join(volume, \"Files\")\n\t\tif _, err := os.Stat(volume); err != nil {\n\t\t\treturn fmt.Errorf(\"no Files folder in layer %s\", layerID)\n\t\t}\n\t}\n\tif err := bindfilter.ApplyFileBinding(target, volume, m.ReadOnly()); err != nil {\n\t\treturn fmt.Errorf(\"failed to set volume mount path for layer %s: %w\", m.Source, err)\n\t}\n\tdefer func() {\n\t\tif retErr != nil {\n\t\t\tif bindErr := bindfilter.RemoveFileBinding(target); bindErr != nil {\n\t\t\t\tlog.G(context.TODO()).WithError(bindErr).Error(\"failed to remove binding during mount failure cleanup\")\n\t\t\t}\n\t\t}\n\t}()\n\n\t// Add an Alternate Data Stream to record the layer source.\n\t// See https://docs.microsoft.com/en-au/archive/blogs/askcore/alternate-data-streams-in-ntfs\n\t// for details on Alternate Data Streams.\n\tif err := os.WriteFile(filepath.Clean(target)+\":\"+sourceStreamName, []byte(m.Source), 0666); err != nil {\n\t\treturn fmt.Errorf(\"failed to record source for layer %s: %w\", m.Source, err)\n\t}\n\n\treturn nil\n}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/containerd/containerd/blob/4246446a2bf7d03837b0244118d858799393bd80/core/mount/mount_windows.go#L73-L109","documentation":"Returned by Mount.mount on Windows when bindfilter.ApplyFileBinding fails to bind the layer volume path to the requested target. This is the final filesystem-binding step after activation, preparation, and mount-path resolution; the wrapped error comes from the bind-filter driver. On failure the deferred cleanup removes any partial binding at the target.","triggerScenarios":"Calling Mount with Type 'windows-layer' when the bind filter cannot create the binding: target path already bound/in use, target invalid or locked, read-only flag unsupported in current state, or the bindfilter driver (Windows feature) is unavailable or failing.","commonSituations":"Target directory already used by another mount (stale binding from a previous failed mount); missing/failed Windows bind filter driver on the host; path conflicts with existing directories or junctions; concurrent mounts racing on the same target path; host with outdated/unsupported Windows build.","solutions":["Ensure the target path is free of stale bindings; call the unmount path (which invokes bindfilter.RemoveFileBinding) or remove leftover junctions, then retry","Check the Windows host has the bind filter driver available and updated (upgrade Windows/containerd if unsupported)","Avoid concurrent mounts to the same target; serialize mount operations per target path","Check permissions on target and volume paths, and Windows event logs for bindfilter errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure target has no stale binding before mounting\nif _, err := os.Stat(filepath.Join(target, \"Files\")); err == nil {\n    // path already populated: a previous binding may be present\n    _ = mount.UnmountAll(target, 0)\n}","typeGuard":"func isBindFilterError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"failed to set volume mount path for layer \")\n}","tryCatchPattern":"err := mount.All(mounts, target)\nif isBindFilterError(err) {\n    // clear stale binding, then retry once\n    _ = mount.UnmountAll(target, 0)\n    return mount.All(mounts, target)\n}","preventionTips":["Serialize mounts per target path to avoid concurrent binding races","Always route cleanup through Unmount/UnmountAll so bindfilter.RemoveFileBinding runs","Verify the Windows host supports the bind filter driver (supported build)","Check for and remove leftover junctions/bindings from crashed mounts"],"tags":["windows","mount","bindfilter"],"backgroundTag":"bind-mount-failed","analyzedSha":"4246446a2bf7d03837b0244118d858799393bd80","analyzedAt":"2026-09-02T00:14:43.053Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}