{"record":{"id":"92b6be8505909aa0","repo":"docker/cli","slug":"cannot-mix-image-options-with-mount-type-s","errorCode":null,"errorMessage":"cannot mix 'image-*' options with mount type '%s'","messagePattern":"cannot mix 'image-\\*' options with mount type '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/mount_utils.go","lineNumber":59,"sourceCode":"// 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.\nfunc parseBoolValue(key string, val string, hasValue bool) (bool, error) {\n\tif !hasValue {\n\t\treturn true, nil","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/mount_utils.go#L41-L77","documentation":"Returned by validateExclusiveOptions (opts/mount_utils.go:59) when a mount's Type is not TypeImage but ImageOptions is non-nil. The image-* options (image-subpath) are only valid for type=image mounts.","triggerScenarios":"Setting image-subpath on a non-image mount, e.g. `--mount type=volume,source=v,target=/d,image-subpath=foo`, or programmatically setting mount.ImageOptions on a Mount whose Type isn't TypeImage.","commonSituations":"Mixing image-mount options into a bind/volume spec, or a templating tool emitting image-subpath unconditionally.","solutions":["Use type=image when you need image-subpath.","Or remove image-subpath from bind/volume/tmpfs/cluster mounts."],"exampleFix":"// before\n--mount \"type=bind,source=/h,target=/d,image-subpath=app/bin\"\n\n// after\n--mount \"type=image,source=myimg,target=/d,image-subpath=app/bin\"","handlingStrategy":"validation","validationCode":"func validateExclusive(m mount.Mount) error {\n    if m.Type != mount.TypeImage && m.ImageOptions != nil {\n        return fmt.Errorf(\"image-* options require type=image, 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 set ImageOptions on type=image mounts.","Isolate image-mount construction in its own builder function.","Test that image-subpath implies type=image."],"tags":["mount","docker","image","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"}