docker/cli ยท error

invalid tmpfs source, source must be empty

Error message

invalid tmpfs source, source must be empty

What it means

Raised by handleTmpfsToMount when a `type: tmpfs` service volume specifies a `source`. A tmpfs mount is an in-memory filesystem created fresh at the target path; it has no backing source by definition, so any non-empty Source field is rejected as a contradiction.

Source

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

	if volume.Tmpfs != nil {
		return mount.Mount{}, errors.New("tmpfs options are incompatible with type bind")
	}
	if volume.Cluster != nil {
		return mount.Mount{}, errors.New("cluster options are incompatible with type bind")
	}
	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,
		}
	}

View on GitHub (pinned to e9452d6e78)

Solutions

  1. Remove the `source:` field from the tmpfs volume entry
  2. If the data must come from a host path or named volume, use `type: bind` or `type: volume` instead

Example fix

# before
volumes:
  - type: tmpfs
    source: mydata
    target: /cache
# after
volumes:
  - type: tmpfs
    target: /cache
    tmpfs:
      size: 100000000

When it happens

Trigger: Compose long-syntax volume with `type: tmpfs` and a non-empty `source:` (or short syntax `src:dst` parsed with a source) converted during `docker stack deploy`.

Common situations: Changing an existing bind/volume entry's type to tmpfs and forgetting to delete `source:`; assuming tmpfs needs a named source like a volume mount; using short syntax `name:/path` with `type: tmpfs` in generated configs.

Related errors


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