{"record":{"id":"31aeb455aebdff19","repo":"docker/cli","slug":"bind-options-are-incompatible-with-type-image","errorCode":null,"errorMessage":"bind options are incompatible with type image","messagePattern":"bind options are incompatible with type image","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":104,"sourceCode":"\t\t\tName:    stackVolume.Driver,\n\t\t\tOptions: stackVolume.DriverOpts,\n\t\t}\n\t}\n\n\treturn result, nil\n}\n\nfunc handleImageToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {\n\tresult := createMountFromVolume(volume)\n\n\tif volume.Source == \"\" {\n\t\treturn mount.Mount{}, errors.New(\"invalid image 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 image\")\n\t}\n\tif volume.Bind != nil {\n\t\treturn mount.Mount{}, errors.New(\"bind options are incompatible with type image\")\n\t}\n\tif volume.Tmpfs != nil {\n\t\treturn mount.Mount{}, errors.New(\"tmpfs options are incompatible with type image\")\n\t}\n\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","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/volume.go#L86-L122","documentation":"Returned by handleImageToMount (volume.go:103-104) when a Compose service volume is type: image but also carries a 'bind' sub-options block (propagation). Bind options only apply to type: bind mounts; combining them with an image mount is rejected during conversion.","triggerScenarios":"In docker-compose.yml: { type: image, source: myimg:latest, target: /app, bind: { propagation: shared } }. volume.Bind non-nil at line 103 triggers the error.","commonSituations":"Converting a bind mount to an image mount and leaving the bind block. YAML merge keys importing a bind block into an image entry. Reusing a mount template across types.","solutions":["Remove the 'bind:' sub-key from the image-type mount.","If propagation semantics are needed, use type: bind with a host path source.","Validate with 'docker compose config'."],"exampleFix":"# before\nvolumes:\n  - type: image\n    source: myimg:latest\n    target: /app\n    bind:\n      propagation: shared\n\n# after\nvolumes:\n  - type: image\n    source: myimg:latest\n    target: /app","handlingStrategy":"validation","validationCode":"// Ensure an image-type mount does not carry bind options.\nfunc validateImageMount(v composetypes.ServiceVolumeConfig) error {\n    if v.Type == \"image\" && v.Bind != nil {\n        return errors.New(\"bind options are incompatible with type image\")\n    }\n    return nil\n}","typeGuard":"// imageMountHasNoForeignOptions reports whether an image-type mount omits volume/bind/tmpfs/cluster.\nfunc imageMountHasNoForeignOptions(v composetypes.ServiceVolumeConfig) bool {\n    if v.Type != \"image\" {\n        return true\n    }\n    return v.Volume == nil && v.Bind == nil && v.Tmpfs == nil && v.Cluster == nil\n}","tryCatchPattern":null,"preventionTips":["Bind propagation only applies to type: bind; remove it from image mounts.","Do not reuse option-block anchors across bind and image mounts.","Run 'docker compose config' to surface the conflict."],"tags":["docker-compose","volumes","image-mount","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"}