docker/cli · error

invalid value for

Error message

invalid value for %s: %s

What it means

Returned by MountOpt.Set (opts/mount.go:130) when the `tmpfs-size` option's value cannot be parsed by go-units' RAMInBytes. The size must be a number optionally followed by a binary/decimal unit suffix (e.g. 1000000, 64m, 2g). A malformed or empty suffix causes RAMInBytes to error and this message wraps it.

Solutions

  1. Use an integer with an accepted suffix: tmpfs-size=64m or tmpfs-size=1073741824.
  2. Avoid fractional sizes (1.5g); round to a whole unit.
  3. Confirm the suffix is one go-units accepts: k/kb/m/mb/g/gb/t/tb (case-insensitive, base 1024 by default).

Example fix

// before
--mount "type=tmpfs,destination=/cache,tmpfs-size=1.5g"

// after
--mount "type=tmpfs,destination=/cache,tmpfs-size=2g"
Defensive patterns

Strategy: validation

Validate before calling

func validateTmpfsSize(v string) error {
    if _, err := units.RAMInBytes(v); err != nil {
        return fmt.Errorf("invalid tmpfs-size %q: %w", v, err)
    }
    return nil
}

Try / catch

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

Prevention

When it happens

Trigger: Passing `tmpfs-size=` (empty — though that's caught earlier), `tmpfs-size=abc`, `tmpfs-size=1.5g` (fractional sizes rejected by RAMInBytes), or a non-existent unit suffix.

Common situations: Using uppercase `64M` is fine, but fractional values, typos like `64mb`, or locale-specific decimals fail.

Related errors


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

Appendix: source

Thrown at opts/mount.go:130

		case "volume-nocopy":
			ensureVolumeOptions(&mount).NoCopy, err = parseBoolValue(key, val, hasValue)
			if err != nil {
				return err
			}
		case "volume-label":
			volumeOpts := ensureVolumeOptions(&mount)
			volumeOpts.Labels = setValueOnMap(volumeOpts.Labels, val)
		case "volume-driver":
			ensureVolumeDriver(&mount).Name = val
		case "volume-opt":
			volumeDriver := ensureVolumeDriver(&mount)
			volumeDriver.Options = setValueOnMap(volumeDriver.Options, val)
		case "image-subpath":
			ensureImageOptions(&mount).Subpath = val
		case "tmpfs-size":
			sizeBytes, err := units.RAMInBytes(val)
			if err != nil {
				return fmt.Errorf("invalid value for %s: %s", key, val)
			}
			ensureTmpfsOptions(&mount).SizeBytes = sizeBytes
		case "tmpfs-mode":
			ui64, err := strconv.ParseUint(val, 8, 32)
			if err != nil {
				return fmt.Errorf("invalid value for %s: %s", key, val)
			}
			ensureTmpfsOptions(&mount).Mode = os.FileMode(ui64)
		default:
			return fmt.Errorf("unknown option '%s' in '%s'", key, field)
		}
	}

	if err := validateMountOptions(&mount); err != nil {
		return err
	}

	m.values = append(m.values, mount)

View on GitHub (pinned to 4f84911bfe)