{"record":{"id":"632e5b231ea5406b","repo":"docker/cli","slug":"invalid-tmpfs-source-source-must-be-empty","errorCode":null,"errorMessage":"invalid tmpfs source, source must be empty","messagePattern":"invalid tmpfs source, source must be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":150,"sourceCode":"\tif volume.Tmpfs != nil {\n\t\treturn mount.Mount{}, errors.New(\"tmpfs options are incompatible with type bind\")\n\t}\n\tif volume.Cluster != nil {\n\t\treturn mount.Mount{}, errors.New(\"cluster options are incompatible with type bind\")\n\t}\n\tif volume.Bind != nil {\n\t\tresult.BindOptions = &mount.BindOptions{\n\t\t\tPropagation: mount.Propagation(volume.Bind.Propagation),\n\t\t}\n\t}\n\treturn result, nil\n}\n\nfunc handleTmpfsToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {\n\tresult := createMountFromVolume(volume)\n\n\tif volume.Source != \"\" {\n\t\treturn mount.Mount{}, errors.New(\"invalid tmpfs source, source must be empty\")\n\t}\n\tif volume.Bind != nil {\n\t\treturn mount.Mount{}, errors.New(\"bind options are incompatible with type tmpfs\")\n\t}\n\tif volume.Volume != nil {\n\t\treturn mount.Mount{}, errors.New(\"volume options are incompatible with type tmpfs\")\n\t}\n\tif volume.Image != nil {\n\t\treturn mount.Mount{}, errors.New(\"image options are incompatible with type tmpfs\")\n\t}\n\tif volume.Cluster != nil {\n\t\treturn mount.Mount{}, errors.New(\"cluster options are incompatible with type tmpfs\")\n\t}\n\tif volume.Tmpfs != nil {\n\t\tresult.TmpfsOptions = &mount.TmpfsOptions{\n\t\t\tSizeBytes: volume.Tmpfs.Size,\n\t\t}\n\t}","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/volume.go#L132-L168","documentation":"Returned by handleTmpfsToMount (cli/compose/convert/volume.go:149-150). Unlike every other type, tmpfs is an anonymous in-memory filesystem and must NOT declare a source path. The guard is the inverse of the bind/npipe/cluster checks: a non-empty source is the error condition.","triggerScenarios":"ServiceVolumeConfig with Type==\"tmpfs\" and Source!=\"\" passed to convertVolumeToMount().","commonSituations":"Adding `type: tmpfs` to a pre-existing volume entry that still has `source:` set; assuming tmpfs needs a source like the other types; converting a bind to tmpfs and forgetting to delete the source line.","solutions":["Remove the `source:` key from the tmpfs entry (only `target` is needed).","If you need a size cap, keep it under `tmpfs: { size: <bytes> }` and leave source empty.","If you actually wanted to mount a host path or named volume, pick `type: bind` or `type: volume` instead."],"exampleFix":"# before\nvolumes:\n  - type: tmpfs\n    source: /tmp/cache\n    target: /cache\n    tmpfs:\n      size: 67108864\n\n# after\nvolumes:\n  - type: tmpfs\n    target: /cache\n    tmpfs:\n      size: 67108864","handlingStrategy":"validation","validationCode":"for i, v := range serviceVolumes {\n    if v.Type == \"tmpfs\" && strings.TrimSpace(v.Source) != \"\" {\n        return fmt.Errorf(\"service volume[%d] target=%q: type tmpfs must have an empty source (it is in-memory)\", i, v.Target)\n    }\n}","typeGuard":null,"tryCatchPattern":"mounts, err := convert.Volumes(serviceVolumes, stackVolumes, namespace)\nif err != nil && strings.Contains(err.Error(), \"invalid tmpfs source\") {\n    return fmt.Errorf(\"compose config error: %w (delete the source: line from the tmpfs entry)\", err)\n}","preventionTips":["Remember tmpfs is the one type where source must be empty — the opposite of bind/npipe/cluster.","When converting another type to tmpfs, delete `source:` first.","Only `target:` (and optional `tmpfs:` options) belong on a tmpfs entry."],"tags":["docker","compose","volumes","tmpfs","config-validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}