{"record":{"id":"b43694285b52c7a7","repo":"docker/cli","slug":"volume-type-must-be-volume-bind-tmpfs-npipe-or","errorCode":null,"errorMessage":"volume type must be volume, bind, tmpfs, npipe, or cluster","messagePattern":"volume type must be volume, bind, tmpfs, npipe, or cluster","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":257,"sourceCode":"\tvolume composetypes.ServiceVolumeConfig,\n\tstackVolumes volumes,\n\tnamespace Namespace,\n) (mount.Mount, error) {\n\tswitch volume.Type {\n\tcase \"volume\", \"\":\n\t\treturn handleVolumeToMount(volume, stackVolumes, namespace)\n\tcase \"image\":\n\t\treturn handleImageToMount(volume)\n\tcase \"bind\":\n\t\treturn handleBindToMount(volume)\n\tcase \"tmpfs\":\n\t\treturn handleTmpfsToMount(volume)\n\tcase \"npipe\":\n\t\treturn handleNpipeToMount(volume)\n\tcase \"cluster\":\n\t\treturn handleClusterToMount(volume, stackVolumes, namespace)\n\t}\n\treturn mount.Mount{}, errors.New(\"volume type must be volume, bind, tmpfs, npipe, or cluster\")\n}\n","sourceCodeStart":239,"sourceCodeEnd":259,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/volume.go#L239-L259","documentation":"Returned by the default branch of convertVolumeToMount (cli/compose/convert/volume.go:257) when volume.Type does not match any handled case. The switch only recognises \"volume\", \"\" (treated as volume at line 244), \"image\", \"bind\", \"tmpfs\", \"npipe\", and \"cluster\"; anything else falls through to this catch-all. Note \"image\" is accepted even though no error mentions it as a default failure — only truly unknown strings reach line 257.","triggerScenarios":"A ServiceVolumeConfig whose Type is an unrecognised string (e.g. \"host\", \"none\", \"Volume\", \"BIND\", or a typo) passed to convertVolumeToMount(). Case matters: \"Volume\" with a capital V will not match \"volume\".","commonSituations":"Typos in `type:`; copy-pasting a non-standard type from another tool; locale/case issues (\"Bind\"); using a type from a newer/older compose spec than this CLI supports; leftover placeholder values like `type: TODO`.","solutions":["Set `type:` to one of the supported lowercase values: volume, bind, tmpfs, npipe, cluster, or image.","Omit `type:` entirely if you want an anonymous named volume (defaults to \"volume\").","Check the docker/compose CLI version against the type you are trying to use — older builds do not recognise newer types."],"exampleFix":"# before\nvolumes:\n  - type: host\n    source: /host/data\n    target: /data\n\n# after\nvolumes:\n  - type: bind\n    source: /host/data\n    target: /data","handlingStrategy":"type-guard","validationCode":"// Validate every volume's type before calling convert.Volumes(...)\nallowed := map[string]bool{\"\": true, \"volume\": true, \"bind\": true, \"tmpfs\": true, \"npipe\": true, \"cluster\": true, \"image\": true}\nfor i, v := range serviceVolumes {\n    if !allowed[v.Type] {\n        return fmt.Errorf(\"service volume[%d] target=%q: unsupported type %q (want volume, bind, tmpfs, npipe, cluster, image, or omitted)\", i, v.Target, v.Type)\n    }\n}","typeGuard":"// isKnownVolumeType narrows a compose volume type string to the set\n// accepted by convertVolumeToMount (cli/compose/convert/volume.go:243).\nfunc isKnownVolumeType(t string) bool {\n    switch t {\n    case \"\", \"volume\", \"image\", \"bind\", \"tmpfs\", \"npipe\", \"cluster\":\n        return true\n    }\n    return false\n}\n\n// usage:\nfor _, v := range serviceVolumes {\n    if !isKnownVolumeType(v.Type) { /* reject early */ }\n}","tryCatchPattern":"mounts, err := convert.Volumes(serviceVolumes, stackVolumes, namespace)\nif err != nil && strings.Contains(err.Error(), \"volume type must be volume, bind, tmpfs, npipe, or cluster\") {\n    return fmt.Errorf(\"compose config error: %w (set type: to a supported lowercase value or omit it for a named volume)\", err)\n}","preventionTips":["Always use lowercase type values — the switch is case-sensitive (\"Volume\" will not match).","If you omit `type:` it defaults to volume; do not invent types like \"host\" or \"none\".","Confirm the docker/compose CLI build supports the type you are using (e.g. older builds lack image/cluster)."],"tags":["docker","compose","volumes","mount-type","config-validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}