{"id":"b56db9a39d60a834","repo":"docker/cli","slug":"volume-options-are-incompatible-with-type-image","errorCode":null,"errorMessage":"volume options are incompatible with type image","messagePattern":"volume options are incompatible with type image","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":101,"sourceCode":"\tresult.VolumeOptions.Labels = addStackLabel(namespace, stackVolume.Labels)\n\tif stackVolume.Driver != \"\" || stackVolume.DriverOpts != nil {\n\t\tresult.VolumeOptions.DriverConfig = &mount.Driver{\n\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","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/compose/convert/volume.go#L83-L119","documentation":"Raised by handleImageToMount when a mount of type 'image' also carries a 'volume:' options block (nocopy, subpath for named volumes). Image mounts accept only image options, so the converter rejects the entry rather than silently dropping the volume options.","triggerScenarios":"'docker stack deploy' with a service volume entry combining type: image and a volume: sub-mapping such as volume: {nocopy: true}.","commonSituations":"Converting a named-volume entry to an image mount and leaving the volume: block behind; note volume.subpath has an image-mount equivalent under image: subpath, which is the usual intended fix.","solutions":["Delete the 'volume:' block; if you needed subpath, move it under 'image:' (image: {subpath: some/dir}).","If a named volume was intended, change type back to volume."],"exampleFix":"# before\nvolumes:\n  - type: image\n    source: alpine:latest\n    target: /mnt/img\n    volume:\n      subpath: etc\n# after\nvolumes:\n  - type: image\n    source: alpine:latest\n    target: /mnt/img\n    image:\n      subpath: etc","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker","compose","image-mount","volume","config-validation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}