docker/compose · error
invalid scale specifier: %s
Error message
invalid scale specifier: %s
What it means
Thrown by parseServicesReplicasArgs in the `docker compose scale` command when an argument cannot be split into a SERVICE=REPLICAS pair. The parser uses strings.Cut on '=' and requires a non-empty service name and a non-empty replica value, so any argument missing '=' or having an empty side is rejected before any project is loaded.
Source
Thrown at cmd/compose/scale.go:119
return backend.Scale(ctx, project, api.ScaleOptions{Services: services})
}
func setServiceScale(project *types.Project, name string, replicas int) error {
service, err := project.GetService(name)
if err != nil {
return err
}
service.SetScale(replicas)
project.Services[name] = service
return nil
}
func parseServicesReplicasArgs(args []string) (map[string]int, error) {
serviceReplicaTuples := map[string]int{}
for _, arg := range args {
key, val, ok := strings.Cut(arg, "=")
if !ok || key == "" || val == "" {
return nil, fmt.Errorf("invalid scale specifier: %s", arg)
}
intValue, err := strconv.Atoi(val)
if err != nil {
return nil, fmt.Errorf("invalid scale specifier: can't parse replica value as int: %v", arg)
}
serviceReplicaTuples[key] = intValue
}
return serviceReplicaTuples, nil
}
View on GitHub (pinned to ddc4b044b6)
Solutions
- Rewrite each argument as SERVICE=REPLICAS, e.g. `docker compose scale web=3 db=2`.
- Check for stray empty arguments produced by unset shell variables (use `${VAR:?}` or quote the full pair).
- If migrating from Compose v1, replace the old space-separated `scale svc count` form with the '=' form.
- Run `docker compose scale --help` to confirm the expected [SERVICE=REPLICAS...] syntax.
Example fix
# before docker compose scale web 3 # after docker compose scale web=3
Defensive patterns
Strategy: validation
Validate before calling
# before calling compose, verify each arg is SERVICE=INT
for arg in "$@"; do
[[ "$arg" =~ ^[A-Za-z0-9._-]+=.+$ ]] || { echo "bad scale arg: $arg" >&2; exit 2; }
done
docker compose scale "$@" Prevention
- Always quote full SERVICE=REPLICAS pairs as one shell word.
- Fail scripts early when computed args are empty (use ${VAR:?required}).
- Remember Compose v2 syntax: one '=' per pair, unlike v1's space-separated form.
When it happens
Trigger: Running `docker compose scale` with an argument like `web` (no '='), `=3` (empty service name), `web=` (empty replica value), or passing flags after args without '--'. cobra.MinimumNArgs(1) passes all args straight into the parser, and the first malformed one aborts the whole command.
Common situations: Muscle memory from `docker-compose scale web 3` (space-separated, old v1 syntax) instead of `web=3`; shell-quoting mistakes that swallow the '='; copy-pasting a service list where one entry is just a name; trailing empty arg from an unquoted variable like `scale ${SVC}=$REPLICAS` when REPLICAS is unset.
Related errors
- invalid scale specifier: can't parse replica value as int: %
- invalid --scale option %q. Should be SERVICE=NUM
- cannot combine %s and --remove-orphans
- no service selected
- --wait-timeout must be a non-negative integer
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/0784bfd3eeb8e520.
Report an issue: GitHub.