{"id":"12c912ee12a668dc","repo":"docker/cli","slug":"images-options-are-incompatible-with-type-volume","errorCode":null,"errorMessage":"images options are incompatible with type volume","messagePattern":"images options are incompatible with type volume","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":45,"sourceCode":"func createMountFromVolume(volume composetypes.ServiceVolumeConfig) mount.Mount {\n\treturn mount.Mount{\n\t\tType:        mount.Type(volume.Type),\n\t\tTarget:      volume.Target,\n\t\tReadOnly:    volume.ReadOnly,\n\t\tSource:      volume.Source,\n\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)","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/compose/convert/volume.go#L27-L63","documentation":"Raised by handleVolumeToMount in the compose-to-swarm volume converter when a service mount of `type: volume` carries an `image:` options block. The image sub-options only apply to image-type mounts, so pairing them with a volume mount is a config contradiction the converter rejects up front (the same guard exists for tmpfs, bind, and cluster options).","triggerScenarios":"`docker stack deploy` where a service volume entry uses long syntax with `type: volume` plus an `image:` key, e.g. `- {type: volume, source: data, target: /data, image: {subpath: ...}}`. Any non-nil Image struct on a volume-type mount triggers it.","commonSituations":"Copying an image-mount example and changing type to volume without removing the image block; YAML indentation mistakes nesting image options under the wrong mount; experimenting with the newer image-mount feature and mixing it into an existing volume definition.","solutions":["Remove the `image:` block from the mount, or change the mount to `type: image` if an image mount is what you want","Check YAML indentation so image options aren't accidentally attached to a volume mount","Validate the file with `docker compose config` before deploying"],"exampleFix":"# before\nvolumes:\n  - type: volume\n    source: data\n    target: /data\n    image:\n      subpath: app\n# after\nvolumes:\n  - type: volume\n    source: data\n    target: /data","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","compose","swarm","mounts","volume","validation"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}