{"record":{"id":"702002ad3e45dc3a","repo":"docker/cli","slug":"cluster-options-are-incompatible-with-type-volume","errorCode":null,"errorMessage":"cluster options are incompatible with type volume","messagePattern":"cluster options are incompatible with type volume","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":54,"sourceCode":"\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 {\n\t\tresult.VolumeOptions.NoCopy = volume.Volume.NoCopy\n\t\tresult.VolumeOptions.Subpath = volume.Volume.Subpath\n\t}","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/volume.go#L36-L72","documentation":"Returned by handleVolumeToMount (volume.go:53-54) when a Compose service volume is type: volume but also carries a 'cluster' sub-options block. Cluster options only apply to type: cluster (Swarm cluster volume) mounts; mixing them into a normal volume mount is rejected during conversion.","triggerScenarios":"In docker-compose.yml: { type: volume, source: data, target: /data, cluster: { } }. volume.Cluster non-nil at line 53 triggers the error.","commonSituations":"Promoting a local volume entry to use cluster options but forgetting to change type to 'cluster'. YAML merge keys importing a cluster block. Template defaults that emit cluster: {} for all mounts.","solutions":["Remove the 'cluster:' sub-key from the volume-type mount.","If cluster-volume semantics are intended, set type: cluster and ensure the source is a defined cluster volume.","Run 'docker compose config' to verify."],"exampleFix":"# before\nvolumes:\n  - type: volume\n    source: data\n    target: /data\n    cluster: {}\n\n# after\nvolumes:\n  - type: cluster\n    source: cdata\n    target: /data","handlingStrategy":"validation","validationCode":"// Ensure a volume-type mount does not carry cluster options.\nfunc validateVolumeMount(v composetypes.ServiceVolumeConfig) error {\n    if (v.Type == \"volume\" || v.Type == \"\") && v.Cluster != nil {\n        return errors.New(\"cluster 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":["Cluster options belong only to type: cluster; remove them from volume mounts.","When promoting a local volume to a cluster volume, also change type to 'cluster'.","Run 'docker compose config' before deploying Swarm stacks."],"tags":["docker-compose","volumes","cluster-volume","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"}