docker/cli ยท error

volume options are incompatible with type tmpfs

Error message

volume options are incompatible with type tmpfs

What it means

Raised by handleTmpfsToMount when a `type: tmpfs` volume carries a `volume:` options block (e.g. nocopy, subpath). Those options configure named-volume mounts only, so the converter fails fast on the inconsistent config.

Source

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

	if volume.Bind != nil {
		result.BindOptions = &mount.BindOptions{
			Propagation: mount.Propagation(volume.Bind.Propagation),
		}
	}
	return result, nil
}

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)

View on GitHub (pinned to e9452d6e78)

Solutions

  1. Remove the `volume:` block from the tmpfs entry
  2. If named-volume semantics (nocopy/subpath) are wanted, use `type: volume` with a `source:` instead

Example fix

# before
volumes:
  - type: tmpfs
    target: /cache
    volume:
      nocopy: true
# after
volumes:
  - type: tmpfs
    target: /cache

When it happens

Trigger: ServiceVolumeConfig with Type tmpfs and Volume != nil, e.g. `type: tmpfs` plus `volume: {nocopy: true}`, during `docker stack deploy`.

Common situations: Converting a named-volume entry to tmpfs and leaving the `volume:` block behind; generated compose files that emit a `volume:` block for every entry regardless of type.

Related errors


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