{"record":{"id":"afc37b9e0e2ed14f","repo":"docker/cli","slug":"cannot-mix-volume-options-with-mount-type-s","errorCode":null,"errorMessage":"cannot mix 'volume-*' options with mount type '%s'","messagePattern":"cannot mix 'volume-\\*' options with mount type '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/mount_utils.go","lineNumber":56,"sourceCode":"}\n\n// validateExclusiveOptions checks if the given mount config only contains\n// options for the given mount-type.\n//\n// This is the client-side equivalent of [mounts.validateExclusiveOptions] in\n// the daemon, but with error-messages matching client-side flags / options.\n//\n// [mounts.validateExclusiveOptions]: https://github.com/moby/moby/blob/v2.0.0-beta.6/daemon/volume/mounts/validate.go#L31-L50\nfunc validateExclusiveOptions(m *mount.Mount) error {\n\tif m.Type == \"\" {\n\t\treturn errors.New(\"type is required\")\n\t}\n\n\tif m.Type != mount.TypeBind && m.BindOptions != nil {\n\t\treturn fmt.Errorf(\"cannot mix 'bind-*' options with mount type '%s'\", m.Type)\n\t}\n\tif m.Type != mount.TypeVolume && m.VolumeOptions != nil {\n\t\treturn fmt.Errorf(\"cannot mix 'volume-*' options with mount type '%s'\", m.Type)\n\t}\n\tif m.Type != mount.TypeImage && m.ImageOptions != nil {\n\t\treturn fmt.Errorf(\"cannot mix 'image-*' options with mount type '%s'\", m.Type)\n\t}\n\tif m.Type != mount.TypeTmpfs && m.TmpfsOptions != nil {\n\t\treturn fmt.Errorf(\"cannot mix 'tmpfs-*' options with mount type '%s'\", m.Type)\n\t}\n\tif m.Type != mount.TypeCluster && m.ClusterOptions != nil {\n\t\treturn fmt.Errorf(\"cannot mix 'cluster-*' options with mount type '%s'\", m.Type)\n\t}\n\treturn nil\n}\n\n// parseBoolValue returns the boolean value represented by the string. It returns\n// true if no value is set.\n//\n// It is similar to [strconv.ParseBool], but only accepts 1, true, 0, false.\n// Any other value returns an error.","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/mount_utils.go#L38-L74","documentation":"Returned by validateExclusiveOptions (opts/mount_utils.go:56) when a mount's Type is not TypeVolume but VolumeOptions is non-nil. Volume-specific options (volume-nocopy, volume-label, volume-driver, volume-opt, volume-subpath) are only permitted with type=volume.","triggerScenarios":"Setting any volume-* option on a type=bind/tmpfs/image/cluster mount, e.g. `--mount type=bind,source=/h,target=/d,volume-nocopy`, or programmatically setting mount.VolumeOptions on a non-volume Mount.","commonSituations":"Copy-pasting a volume mount spec and changing only the type, or a generator that always emits volume-driver.","solutions":["Use type=volume if you need volume-* options.","Or strip all volume-* options when mounting as bind/tmpfs/image/cluster."],"exampleFix":"// before\n--mount \"type=bind,source=/h,target=/d,volume-driver=local\"\n\n// after\n--mount \"type=volume,source=v,target=/d,volume-driver=local\"","handlingStrategy":"validation","validationCode":"func validateExclusive(m mount.Mount) error {\n    if m.Type != mount.TypeVolume && m.VolumeOptions != nil {\n        return fmt.Errorf(\"volume-* options require type=volume, got %s\", m.Type)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := m.Set(spec); err != nil {\n    return fmt.Errorf(\"mount %q: %w\", spec, err)\n}","preventionTips":["Only attach VolumeOptions when Type == TypeVolume.","When converting a volume mount to bind, clear VolumeOptions.","Validate type/options pairing in a shared helper before submission."],"tags":["mount","docker","volume","exclusive-options","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}