{"record":{"id":"3a8eddc5e9f78c7b","repo":"docker/cli","slug":"bind-options-are-incompatible-with-type-volume","errorCode":null,"errorMessage":"bind options are incompatible with type volume","messagePattern":"bind options are incompatible with type volume","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":51,"sourceCode":"\t\tConsistency: mount.Consistency(volume.Consistency),\n\t}\n}\n\nfunc handleVolumeToMount(\n\tvolume composetypes.ServiceVolumeConfig,\n\tstackVolumes volumes,\n\tnamespace Namespace,\n) (mount.Mount, error) {\n\tresult := createMountFromVolume(volume)\n\n\tif volume.Image != nil {\n\t\treturn mount.Mount{}, errors.New(\"images options are incompatible with type volume\")\n\t}\n\tif volume.Tmpfs != nil {\n\t\treturn mount.Mount{}, errors.New(\"tmpfs options are incompatible with type volume\")\n\t}\n\tif volume.Bind != nil {\n\t\treturn mount.Mount{}, errors.New(\"bind options are incompatible with type volume\")\n\t}\n\tif volume.Cluster != nil {\n\t\treturn mount.Mount{}, errors.New(\"cluster options are incompatible with type volume\")\n\t}\n\t// Anonymous volumes\n\tif volume.Source == \"\" {\n\t\treturn result, nil\n\t}\n\n\tstackVolume, exists := stackVolumes[volume.Source]\n\tif !exists {\n\t\treturn mount.Mount{}, fmt.Errorf(\"undefined volume %q\", volume.Source)\n\t}\n\n\tresult.Source = namespace.Scope(volume.Source)\n\tresult.VolumeOptions = &mount.VolumeOptions{}\n\n\tif volume.Volume != nil {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/volume.go#L33-L69","documentation":"Returned by handleVolumeToMount (volume.go:50-51) when a Compose service volume is type: volume but also carries a 'bind' sub-options block (e.g. propagation). Bind options only apply to type: bind mounts; combining them with a volume mount is rejected during conversion.","triggerScenarios":"In docker-compose.yml: { type: volume, source: data, target: /data, bind: { propagation: rshared } }. volume.Bind non-nil at line 50 triggers the error.","commonSituations":"Switching a mount from bind to volume (e.g. to use a named volume) but leaving the propagation/bind options. YAML merge keys importing a bind block. Copy-paste from a bind example.","solutions":["Remove the 'bind:' sub-key from the volume-type mount.","If you need bind propagation semantics, set type: bind and supply a host path as source.","Validate with 'docker compose config'."],"exampleFix":"# before\nvolumes:\n  - type: volume\n    source: data\n    target: /data\n    bind:\n      propagation: rshared\n\n# after\nvolumes:\n  - type: volume\n    source: data\n    target: /data","handlingStrategy":"validation","validationCode":"// Ensure a volume-type mount does not carry bind options.\nfunc validateVolumeMount(v composetypes.ServiceVolumeConfig) error {\n    if (v.Type == \"volume\" || v.Type == \"\") && v.Bind != nil {\n        return errors.New(\"bind options are incompatible with type volume\")\n    }\n    return nil\n}","typeGuard":"// volumeMountHasNoForeignOptions reports whether a volume-type mount omits image/tmpfs/bind/cluster.\nfunc volumeMountHasNoForeignOptions(v composetypes.ServiceVolumeConfig) bool {\n    if v.Type != \"volume\" && v.Type != \"\" {\n        return true\n    }\n    return v.Image == nil && v.Tmpfs == nil && v.Bind == nil && v.Cluster == nil\n}","tryCatchPattern":null,"preventionTips":["When switching from bind to volume, drop propagation/bind sub-options.","Avoid option-block YAML anchors shared between bind and volume mounts.","Validate with 'docker compose config'."],"tags":["docker-compose","volumes","bind","mount","type-conflict","validation","convert"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}