{"record":{"id":"40fe6fb457d40177","repo":"docker/cli","slug":"image-options-are-incompatible-with-type-bind","errorCode":null,"errorMessage":"image options are incompatible with type bind","messagePattern":"image options are incompatible with type bind","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":130,"sourceCode":"\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\nfunc handleTmpfsToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {\n\tresult := createMountFromVolume(volume)\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/volume.go#L112-L148","documentation":"Returned by handleBindToMount (cli/compose/convert/volume.go:129-130). Image options (image.subpath) select a path inside an image layer and only make sense for `type: image`; combining them with `type: bind` is contradictory, so the converter rejects it at cli/compose/convert/volume.go:130.","triggerScenarios":"ServiceVolumeConfig with Type==\"bind\" and Image!=nil passed to convertVolumeToMount().","commonSituations":"Converting an image-backed volume to a bind without removing the `image:` block; merge keys pulling in an image block.","solutions":["Remove the `image:` options block from the bind entry.","If image subpath was intended, change `type:` to `image` and supply an image reference as `source`."],"exampleFix":"# before\nvolumes:\n  - type: bind\n    source: /host/data\n    target: /data\n    image:\n      subpath: /app/assets\n\n# after\nvolumes:\n  - type: bind\n    source: /host/data\n    target: /data","handlingStrategy":"validation","validationCode":"for i, v := range serviceVolumes {\n    if v.Type == \"bind\" && v.Image != nil {\n        return fmt.Errorf(\"service volume[%d] target=%q: type bind must not declare an image block\", i, v.Target)\n    }\n}","typeGuard":null,"tryCatchPattern":"mounts, err := convert.Volumes(serviceVolumes, stackVolumes, namespace)\nif err != nil && strings.Contains(err.Error(), \"image options are incompatible with type bind\") {\n    return fmt.Errorf(\"compose config error: %w (remove the image: block from the bind entry)\", err)\n}","preventionTips":["Treat `type:` and its options block as a paired unit; change both together.","Run `docker compose config` to catch mismatches before runtime."],"tags":["docker","compose","volumes","bind-mount","image-mount","config-validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}