docker/cli · error

cannot mix 'tmpfs-*' options with mount type

Error message

cannot mix 'tmpfs-*' options with mount type '%s'

What it means

Returned by validateExclusiveOptions (opts/mount_utils.go:62) when a mount's Type is not TypeTmpfs but TmpfsOptions is non-nil. The tmpfs-* options (tmpfs-size, tmpfs-mode) are exclusive to type=tmpfs.

Solutions

  1. Use type=tmpfs to keep tmpfs-size/tmpfs-mode.
  2. Or remove tmpfs-* options from non-tmpfs mounts.

Example fix

// before
--mount "type=volume,source=v,target=/d,tmpfs-size=64m"

// after
--mount "type=tmpfs,destination=/d,tmpfs-size=64m"
Defensive patterns

Strategy: validation

Validate before calling

func validateExclusive(m mount.Mount) error {
    if m.Type != mount.TypeTmpfs && m.TmpfsOptions != nil {
        return fmt.Errorf("tmpfs-* options require type=tmpfs, got %s", m.Type)
    }
    return nil
}

Try / catch

if err := m.Set(spec); err != nil {
    return fmt.Errorf("mount %q: %w", spec, err)
}

Prevention

When it happens

Trigger: Setting tmpfs-size or tmpfs-mode on a bind/volume/image/cluster mount, e.g. `--mount type=volume,source=v,target=/d,tmpfs-size=64m`, or programmatically setting mount.TmpfsOptions on a non-tmpfs Mount.

Common situations: Converting a tmpfs mount to a volume but leaving tmpfs options, or generators that always attach TmpfsOptions.

Related errors


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

Appendix: source

Thrown at opts/mount_utils.go:62

// the daemon, but with error-messages matching client-side flags / options.
//
// [mounts.validateExclusiveOptions]: https://github.com/moby/moby/blob/v2.0.0-beta.6/daemon/volume/mounts/validate.go#L31-L50
func validateExclusiveOptions(m *mount.Mount) error {
	if m.Type == "" {
		return errors.New("type is required")
	}

	if m.Type != mount.TypeBind && m.BindOptions != nil {
		return fmt.Errorf("cannot mix 'bind-*' options with mount type '%s'", m.Type)
	}
	if m.Type != mount.TypeVolume && m.VolumeOptions != nil {
		return fmt.Errorf("cannot mix 'volume-*' options with mount type '%s'", m.Type)
	}
	if m.Type != mount.TypeImage && m.ImageOptions != nil {
		return fmt.Errorf("cannot mix 'image-*' options with mount type '%s'", m.Type)
	}
	if m.Type != mount.TypeTmpfs && m.TmpfsOptions != nil {
		return fmt.Errorf("cannot mix 'tmpfs-*' options with mount type '%s'", m.Type)
	}
	if m.Type != mount.TypeCluster && m.ClusterOptions != nil {
		return fmt.Errorf("cannot mix 'cluster-*' options with mount type '%s'", m.Type)
	}
	return nil
}

// parseBoolValue returns the boolean value represented by the string. It returns
// true if no value is set.
//
// It is similar to [strconv.ParseBool], but only accepts 1, true, 0, false.
// Any other value returns an error.
func parseBoolValue(key string, val string, hasValue bool) (bool, error) {
	if !hasValue {
		return true, nil
	}
	switch val {
	case "1", "true":

View on GitHub (pinned to 4f84911bfe)