docker/cli · error
value is empty
Error message
value is empty
What it means
Returned by MountOpt.Set (opts/mount.go:27) when the value passed to a --mount flag, after strings.TrimSpace, is an empty string. This is the first validation check in the mount-option parser; an empty mount string cannot be parsed into any mount configuration.
Solutions
- Ensure the --mount flag receives a non-empty value such as 'type=volume,source=myvol,target=/data'.
- Check that shell variables used in --mount are set and non-empty before use.
- Skip empty mount strings programmatically rather than passing them to Set.
Example fix
// before: empty mount value // docker run --mount "" nginx // after: valid mount spec // docker run --mount type=volume,source=myvol,target=/data nginx
Defensive patterns
Strategy: validation
Validate before calling
func validateMountValue(value string) error {
if strings.TrimSpace(value) == "" {
return fmt.Errorf("mount spec must not be empty")
}
return nil
} Try / catch
if err := mountOpt.Set(value); err != nil {
if err.Error() == "value is empty" {
return fmt.Errorf("--mount requires a non-empty value, e.g., type=volume,source=vol,target=/data")
}
return err
} Prevention
- Skip empty mount strings rather than passing them to MountOpt.Set.
- Ensure shell variables in --mount flags are set and non-empty.
- Validate mount specs from config files at load time.
When it happens
Trigger: MountOpt.Set("") or MountOpt.Set(" ") is called — the --mount flag receives an empty or whitespace-only value.
Common situations: Shell variable expansion to empty string in a --mount flag (e.g., --mount "$MOUNT_OPTS" where MOUNT_OPTS is unset), empty mount entry in a script or config, or a quoting error that produces an empty argument.
Related errors
- images options are incompatible with type volume
- tmpfs options are incompatible with type volume
- bind options are incompatible with type volume
- cluster options are incompatible with type volume
- invalid image source, source cannot be empty
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/ed273418a2dd8a26.
Report an issue: GitHub.
Appendix: source
Thrown at opts/mount.go:27
"strconv"
"strings"
"github.com/docker/go-units"
mounttypes "github.com/moby/moby/api/types/mount"
)
// MountOpt is a Value type for parsing mounts
type MountOpt struct {
values []mounttypes.Mount
}
// Set a new mount value
//
//nolint:gocyclo
func (m *MountOpt) Set(value string) error {
value = strings.TrimSpace(value)
if value == "" {
return errors.New("value is empty")
}
csvReader := csv.NewReader(strings.NewReader(value))
fields, err := csvReader.Read()
if err != nil {
return err
}
mount := mounttypes.Mount{
Type: mounttypes.TypeVolume, // default to volume mounts
}
for _, field := range fields {
key, val, hasValue := strings.Cut(field, "=")
if k := strings.TrimSpace(key); k != key {
return fmt.Errorf("invalid option '%s' in '%s': option should not have whitespace", k, field)
}
if hasValue {View on GitHub (pinned to 4f84911bfe)