{"id":"f4ce5a483d23dcbf","repo":"docker/cli","slug":"volume-options-are-incompatible-with-type-bind","errorCode":null,"errorMessage":"volume options are incompatible with type bind","messagePattern":"volume options are incompatible with type bind","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":127,"sourceCode":"\tif volume.Cluster != nil {\n\t\treturn mount.Mount{}, errors.New(\"cluster options are incompatible with type image\")\n\t}\n\tif volume.Image != nil {\n\t\tresult.ImageOptions = &mount.ImageOptions{\n\t\t\tSubpath: volume.Image.Subpath,\n\t\t}\n\t}\n\treturn result, nil\n}\n\nfunc handleBindToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {\n\tresult := createMountFromVolume(volume)\n\n\tif volume.Source == \"\" {\n\t\treturn mount.Mount{}, errors.New(\"invalid bind source, source cannot be empty\")\n\t}\n\tif volume.Volume != nil {\n\t\treturn mount.Mount{}, errors.New(\"volume options are incompatible with type bind\")\n\t}\n\tif volume.Image != nil {\n\t\treturn mount.Mount{}, errors.New(\"image options are incompatible with type bind\")\n\t}\n\tif volume.Tmpfs != nil {\n\t\treturn mount.Mount{}, errors.New(\"tmpfs options are incompatible with type bind\")\n\t}\n\tif volume.Cluster != nil {\n\t\treturn mount.Mount{}, errors.New(\"cluster options are incompatible with type bind\")\n\t}\n\tif volume.Bind != nil {\n\t\tresult.BindOptions = &mount.BindOptions{\n\t\t\tPropagation: mount.Propagation(volume.Bind.Propagation),\n\t\t}\n\t}\n\treturn result, nil\n}\n","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/compose/convert/volume.go#L109-L145","documentation":"Raised by handleBindToMount when a mount of type 'bind' also carries a 'volume:' options block (nocopy/subpath). Those options only make sense for named volumes, so the converter rejects the mixed entry rather than silently ignoring them.","triggerScenarios":"'docker stack deploy' with a service volume entry combining type: bind and volume: options such as volume: {nocopy: true}.","commonSituations":"Switching a named-volume entry to a host bind mount and forgetting to delete the volume: block; YAML anchors applying volume defaults to every mount.","solutions":["Remove the 'volume:' block from the bind entry; for a subdirectory of the host path, just extend the source path itself.","If named-volume semantics (nocopy, subpath) are needed, change type back to volume and define the volume in the top-level volumes section."],"exampleFix":"# before\nvolumes:\n  - type: bind\n    source: /srv/data\n    target: /data\n    volume:\n      nocopy: true\n# after\nvolumes:\n  - type: bind\n    source: /srv/data\n    target: /data","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker","compose","bind","volume","config-validation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}