{"record":{"id":"88e20d153fe59cfb","repo":"docker/cli","slug":"tmpfs-options-are-incompatible-with-type-image","errorCode":null,"errorMessage":"tmpfs options are incompatible with type image","messagePattern":"tmpfs options are incompatible with type image","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/compose/convert/volume.go","lineNumber":107,"sourceCode":"\t}\n\n\treturn result, nil\n}\n\nfunc handleImageToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {\n\tresult := createMountFromVolume(volume)\n\n\tif volume.Source == \"\" {\n\t\treturn mount.Mount{}, errors.New(\"invalid image source, source cannot be empty\")\n\t}\n\tif volume.Volume != nil {\n\t\treturn mount.Mount{}, errors.New(\"volume options are incompatible with type image\")\n\t}\n\tif volume.Bind != nil {\n\t\treturn mount.Mount{}, errors.New(\"bind options are incompatible with type image\")\n\t}\n\tif volume.Tmpfs != nil {\n\t\treturn mount.Mount{}, errors.New(\"tmpfs options are incompatible with type image\")\n\t}\n\tif volume.Cluster != nil {\n\t\treturn mount.Mount{}, errors.New(\"cluster options are incompatible with type image\")\n\t}\n\tif volume.Image != nil {\n\t\tresult.ImageOptions = &mount.ImageOptions{\n\t\t\tSubpath: volume.Image.Subpath,\n\t\t}\n\t}\n\treturn result, nil\n}\n\nfunc handleBindToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {\n\tresult := createMountFromVolume(volume)\n\n\tif volume.Source == \"\" {\n\t\treturn mount.Mount{}, errors.New(\"invalid bind source, source cannot be empty\")\n\t}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/compose/convert/volume.go#L89-L125","documentation":"Returned by handleImageToMount (volume.go:106-107) when a Compose service volume is type: image but also carries a 'tmpfs' sub-options block (size). tmpfs options only apply to type: tmpfs mounts; combining them with an image mount is rejected during conversion.","triggerScenarios":"In docker-compose.yml: { type: image, source: myimg:latest, target: /app, tmpfs: { size: 1000000000 } }. volume.Tmpfs non-nil at line 106 triggers the error.","commonSituations":"Switching a tmpfs mount to an image mount and leaving the tmpfs options. YAML anchors merging a tmpfs block into an image entry. Reusing a generic mount template that always emits tmpfs.","solutions":["Remove the 'tmpfs:' sub-key from the image-type mount.","If in-memory size-capped semantics are intended, use type: tmpfs (and drop the image source).","Validate with 'docker compose config'."],"exampleFix":"# before\nvolumes:\n  - type: image\n    source: myimg:latest\n    target: /app\n    tmpfs:\n      size: 1000000000\n\n# after\nvolumes:\n  - type: image\n    source: myimg:latest\n    target: /app","handlingStrategy":"validation","validationCode":"// Ensure an image-type mount does not carry tmpfs options.\nfunc validateImageMount(v composetypes.ServiceVolumeConfig) error {\n    if v.Type == \"image\" && v.Tmpfs != nil {\n        return errors.New(\"tmpfs options are incompatible with type image\")\n    }\n    return nil\n}","typeGuard":"// imageMountHasNoForeignOptions reports whether an image-type mount omits volume/bind/tmpfs/cluster.\nfunc imageMountHasNoForeignOptions(v composetypes.ServiceVolumeConfig) bool {\n    if v.Type != \"image\" {\n        return true\n    }\n    return v.Volume == nil && v.Bind == nil && v.Tmpfs == nil && v.Cluster == nil\n}","tryCatchPattern":null,"preventionTips":["tmpfs size options only apply to type: tmpfs; remove them from image mounts.","Avoid generic mount templates that emit all option blocks regardless of type.","Validate compose files with 'docker compose config' in CI."],"tags":["docker-compose","volumes","image-mount","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"}