{"record":{"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/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/volume.go#L109-L145","documentation":"Returned by handleBindToMount (cli/compose/convert/volume.go:126-127). The bind type only honours bind-specific options (propagation); volume options such as nocopy/subpath belong to named volumes and are rejected for binds. Supplying both signals a confused config that the converter will not silently fix.","triggerScenarios":"ServiceVolumeConfig with Type==\"bind\" and Volume!=nil (the `volume:` options block) reaching convertVolumeToMount().","commonSituations":"Changing `type: volume` to `type: bind` but leaving the `volume: { nocopy: true }` block in place; copy-paste from a named-volume example.","solutions":["Delete the `volume:` options block from the bind entry.","If nocopy/subpath was intended, switch the entry back to `type: volume` and provide a named source defined under the top-level `volumes:` map.","Move propagation settings into the `bind:` block (e.g. `bind: { propagation: rshared }`)."],"exampleFix":"# before\nvolumes:\n  - type: bind\n    source: /host/data\n    target: /data\n    volume:\n      nocopy: true\n\n# after\nvolumes:\n  - type: bind\n    source: /host/data\n    target: /data\n    bind:\n      propagation: rshared","handlingStrategy":"validation","validationCode":"for i, v := range serviceVolumes {\n    if v.Type == \"bind\" && v.Volume != nil {\n        return fmt.Errorf(\"service volume[%d] target=%q: type bind must not declare a volume block\", i, v.Target)\n    }\n}","typeGuard":null,"tryCatchPattern":"mounts, err := convert.Volumes(serviceVolumes, stackVolumes, namespace)\nif err != nil && strings.Contains(err.Error(), \"volume options are incompatible with type bind\") {\n    return fmt.Errorf(\"compose config error: %w (remove the volume: block from the bind entry)\", err)\n}","preventionTips":["When changing a volume's `type:`, audit its option blocks in the same edit.","Prefer one canonical options block per type in shared anchors to avoid cross-type leakage."],"tags":["docker","compose","volumes","bind-mount","named-volume","config-validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}