docker/cli ยท error
invalid type %T for duration
Error message
invalid type %T for duration
What it means
Error "invalid type %T for duration" thrown in docker/cli.
Source
Thrown at cli/compose/loader/loader.go:915
switch value := value.(type) {
case int:
return int64(value), nil
case string:
return units.RAMInBytes(value)
}
panic(fmt.Errorf("invalid type for size %T", value))
}
var transformStringToDuration TransformerFunc = func(value any) (any, error) {
switch value := value.(type) {
case string:
d, err := time.ParseDuration(value)
if err != nil {
return value, err
}
return types.Duration(d), nil
default:
return value, fmt.Errorf("invalid type %T for duration", value)
}
}
func toServicePortConfigs(value string) ([]any, error) {
// short syntax ([ip:]public:private[/proto])
//
// TODO(thaJeztah): we need an equivalent that handles the "ip-address" part without depending on the nat package.
ports, portBindings, err := nat.ParsePortSpecs([]string{value})
if err != nil {
return nil, err
}
// We need to sort the key of the ports to make sure it is consistent
keys := make([]string, 0, len(ports))
for port := range ports {
keys = append(keys, string(port))
}
sort.Strings(keys)
View on GitHub (pinned to e9452d6e78)
When it happens
Trigger: Thrown at cli/compose/loader/loader.go:915 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/f9f7a4073d11c984.json.
Report an issue: GitHub.