docker/cli · error

tmpfs options are incompatible with type bind

Error message

tmpfs options are incompatible with type bind

What it means

Returned by handleBindToMount (cli/compose/convert/volume.go:132-133). tmpfs options (size) describe an in-memory filesystem and are incompatible with a bind mount, which references a host path. The converter refuses to honour both at once.

Solutions

  1. Remove the `tmpfs:` options block from the bind entry.
  2. If a size-capped in-memory filesystem was intended, change `type:` to `tmpfs` (and remember tmpfs must have no source).

Example fix

# before
volumes:
  - type: bind
    source: /host/data
    target: /data
    tmpfs:
      size: 67108864

# after
volumes:
  - type: bind
    source: /host/data
    target: /data
Defensive patterns

Strategy: validation

Validate before calling

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

Try / catch

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

Prevention

When it happens

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

Common situations: Switching a tmpfs entry to a bind but leaving `tmpfs: { size: ... }` behind; template merge bringing in a tmpfs block.

Related errors


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

Appendix: source

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

		}
	}
	return result, nil
}

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

	if volume.Source == "" {
		return mount.Mount{}, errors.New("invalid bind source, source cannot be empty")
	}
	if volume.Volume != nil {
		return mount.Mount{}, errors.New("volume options are incompatible with type bind")
	}
	if volume.Image != nil {
		return mount.Mount{}, errors.New("image options are incompatible with type bind")
	}
	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")
	}

View on GitHub (pinned to 4f84911bfe)