docker/cli · error

cluster options are incompatible with type tmpfs

Error message

cluster options are incompatible with type tmpfs

What it means

Returned by handleTmpfsToMount (cli/compose/convert/volume.go:161-162). Cluster options describe Swarm cluster volumes and are meaningless for a local in-memory tmpfs; the converter rejects the combination. ClusterOpts is empty, so `cluster:` or `cluster: {}` both trip it.

Solutions

  1. Remove the `cluster:` key from the tmpfs entry.
  2. If a Swarm cluster volume was intended, change `type:` to `cluster`, drop `tmpfs:`/`bind:`/`volume:`/`image:` blocks, and set a non-empty source.

Example fix

# before
volumes:
  - type: tmpfs
    target: /cache
    cluster: {}

# after
volumes:
  - type: tmpfs
    target: /cache
Defensive patterns

Strategy: validation

Validate before calling

for i, v := range serviceVolumes {
    if v.Type == "tmpfs" && v.Cluster != nil {
        return fmt.Errorf("service volume[%d] target=%q: type tmpfs must not declare a cluster block", i, v.Target)
    }
}

Try / catch

mounts, err := convert.Volumes(serviceVolumes, stackVolumes, namespace)
if err != nil && strings.Contains(err.Error(), "cluster options are incompatible with type tmpfs") {
    return fmt.Errorf("compose config error: %w (remove the cluster: block from the tmpfs entry)", err)
}

Prevention

When it happens

Trigger: ServiceVolumeConfig with Type=="tmpfs" and Cluster!=nil passed to convertVolumeToMount().

Common situations: Migrating a cluster volume entry to tmpfs without stripping the `cluster:` key; YAML anchors injecting the field.

Related errors


AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07). Data as JSON: /api/errors/335e54356fe05a2e. Report an issue: GitHub.

Appendix: source

Thrown at cli/compose/convert/volume.go:162

}

func handleTmpfsToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {
	result := createMountFromVolume(volume)

	if volume.Source != "" {
		return mount.Mount{}, errors.New("invalid tmpfs source, source must be empty")
	}
	if volume.Bind != nil {
		return mount.Mount{}, errors.New("bind options are incompatible with type tmpfs")
	}
	if volume.Volume != nil {
		return mount.Mount{}, errors.New("volume options are incompatible with type tmpfs")
	}
	if volume.Image != nil {
		return mount.Mount{}, errors.New("image options are incompatible with type tmpfs")
	}
	if volume.Cluster != nil {
		return mount.Mount{}, errors.New("cluster options are incompatible with type tmpfs")
	}
	if volume.Tmpfs != nil {
		result.TmpfsOptions = &mount.TmpfsOptions{
			SizeBytes: volume.Tmpfs.Size,
		}
	}
	return result, nil
}

func handleNpipeToMount(volume composetypes.ServiceVolumeConfig) (mount.Mount, error) {
	result := createMountFromVolume(volume)

	if volume.Source == "" {
		return mount.Mount{}, errors.New("invalid npipe source, source cannot be empty")
	}
	if volume.Volume != nil {
		return mount.Mount{}, errors.New("volume options are incompatible with type npipe")
	}

View on GitHub (pinned to 4f84911bfe)