docker/cli ยท error

tmpfs options are incompatible with type volume

Error message

tmpfs options are incompatible with type volume

What it means

Raised by handleVolumeToMount when a service mount of `type: volume` includes a `tmpfs:` options block (size/mode). Tmpfs options are only valid for `type: tmpfs` mounts; on a named/anonymous volume they are contradictory, so the converter rejects the mount during `docker stack deploy` conversion.

Source

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

		Target:      volume.Target,
		ReadOnly:    volume.ReadOnly,
		Source:      volume.Source,
		Consistency: mount.Consistency(volume.Consistency),
	}
}

func handleVolumeToMount(
	volume composetypes.ServiceVolumeConfig,
	stackVolumes volumes,
	namespace Namespace,
) (mount.Mount, error) {
	result := createMountFromVolume(volume)

	if volume.Image != nil {
		return mount.Mount{}, errors.New("images options are incompatible with type volume")
	}
	if volume.Tmpfs != nil {
		return mount.Mount{}, errors.New("tmpfs options are incompatible with type volume")
	}
	if volume.Bind != nil {
		return mount.Mount{}, errors.New("bind options are incompatible with type volume")
	}
	if volume.Cluster != nil {
		return mount.Mount{}, errors.New("cluster options are incompatible with type volume")
	}
	// Anonymous volumes
	if volume.Source == "" {
		return result, nil
	}

	stackVolume, exists := stackVolumes[volume.Source]
	if !exists {
		return mount.Mount{}, fmt.Errorf("undefined volume %q", volume.Source)
	}

	result.Source = namespace.Scope(volume.Source)

View on GitHub (pinned to e9452d6e78)

Solutions

  1. Change the mount to `type: tmpfs` if in-memory storage with the tmpfs options is intended
  2. Remove the `tmpfs:` block if a persistent volume is intended (use driver_opts on the volume definition for size limits where the driver supports it)
  3. Run `docker compose config` to verify the merged mount definitions

Example fix

# before
volumes:
  - type: volume
    source: cache
    target: /cache
    tmpfs:
      size: 104857600
# after
volumes:
  - type: tmpfs
    target: /cache
    tmpfs:
      size: 104857600

When it happens

Trigger: `docker stack deploy` with a long-syntax volume entry combining `type: volume` and `tmpfs: {size: ...}`. Any non-nil Tmpfs struct on a volume-type mount fails the check before the service is created.

Common situations: Changing a tmpfs mount to a persistent volume but leaving the tmpfs size option behind; YAML indentation errors attaching tmpfs options to the wrong list entry; assuming size limits can be set on regular volumes via tmpfs options.

Related errors


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/aecd50a9a867133b.json. Report an issue: GitHub.