{"record":{"id":"aecd50a9a867133b","repo":"docker/cli","slug":"tmpfs-options-are-incompatible-with-type-volume","errorCode":null,"errorMessage":"tmpfs options are incompatible with type volume","messagePattern":"tmpfs options are incompatible with type volume","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":48,"sourceCode":"\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)\n\t}\n\n\tresult.Source = namespace.Scope(volume.Source)","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/volume.go#L30-L66","documentation":"Returned by handleVolumeToMount (volume.go:47-48) when a Compose service volume is type: volume but also carries a 'tmpfs' sub-options block. tmpfs options (e.g. size) only apply to type: tmpfs mounts; mixing them into a volume mount is rejected during conversion.","triggerScenarios":"In docker-compose.yml: { type: volume, source: data, target: /data, tmpfs: { size: 1000000000 } }. volume.Tmpfs non-nil at line 47 triggers the error.","commonSituations":"Changing a mount's type from tmpfs to volume but leaving the tmpfs options behind. YAML anchors merging a tmpfs block into a volume entry. Copy-paste from a tmpfs example.","solutions":["Remove the 'tmpfs:' sub-key from the volume-type mount.","If tmpfs semantics (in-memory, size-capped) are intended, set type: tmpfs and drop the volume source.","Run 'docker compose config' to confirm the cleaned-up file."],"exampleFix":"# before\nvolumes:\n  - type: volume\n    source: data\n    target: /data\n    tmpfs:\n      size: 1000000000\n\n# after\nvolumes:\n  - type: volume\n    source: data\n    target: /data","handlingStrategy":"validation","validationCode":"// Ensure a volume-type mount does not carry tmpfs options.\nfunc validateVolumeMount(v composetypes.ServiceVolumeConfig) error {\n    if (v.Type == \"volume\" || v.Type == \"\") && v.Tmpfs != nil {\n        return errors.New(\"tmpfs 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":["When changing a mount's type, remove the previous type's option block.","Do not share YAML anchors for option blocks across different mount types.","Use 'docker compose config' to catch mismatches early."],"tags":["docker-compose","volumes","tmpfs","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"}