{"record":{"id":"87e19f82b963fdf4","repo":"docker/compose","slug":"invalid-scale-option-q-should-be-service-num","errorCode":null,"errorMessage":"invalid --scale option %q. Should be SERVICE=NUM","messagePattern":"invalid --scale option %q\\. Should be SERVICE=NUM","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/compose/create.go","lineNumber":203,"sourceCode":"\t\t}\n\t}\n\n\tif err := applyPlatforms(project, true); err != nil {\n\t\treturn err\n\t}\n\n\terr := applyScaleOpts(project, opts.scale)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc applyScaleOpts(project *types.Project, opts []string) error {\n\tfor _, scale := range opts {\n\t\tname, val, ok := strings.Cut(scale, \"=\")\n\t\tif !ok || val == \"\" {\n\t\t\treturn fmt.Errorf(\"invalid --scale option %q. Should be SERVICE=NUM\", scale)\n\t\t}\n\t\treplicas, err := strconv.Atoi(val)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = setServiceScale(project, name, replicas)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nvar validPullPolicies = []string{\n\ttypes.PullPolicyAlways, types.PullPolicyNever, types.PullPolicyBuild,\n\ttypes.PullPolicyMissing, types.PullPolicyIfNotPresent,\n}\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/cmd/compose/create.go#L185-L221","documentation":"Each `--scale SERVICE=NUM` argument must contain an `=` with a non-empty numeric right side. applyScaleOpts uses strings.Cut on the first `=`; if there is no `=` or the value part is empty, the argument is rejected with this message before strconv.Atoi is attempted.","triggerScenarios":"Passing `--scale web` (missing `=NUM`), `--scale web=` (empty value), or quoting mistakes such as `--scale \"web = 3\"` where the value becomes ` 3`/name `web ` or the cut leaves an empty tail.","commonSituations":"CI variables like `--scale web=${REPLICAS}` with REPLICAS unset producing `web=`; scripts building the arg by concatenation and dropping the value; users expecting space-separated `--scale web 3`.","solutions":["Write the argument as `--scale SERVICE=NUM`, e.g. `--scale web=3`.","Default the numeric variable: `--scale web=${REPLICAS:-1}` so the value is never empty.","Note the repeatable-flag form: pass `--scale` once per service, not a comma-separated list."],"exampleFix":"# before\ndocker compose up --scale web=${REPLICAS}  # REPLICAS empty\n\n# after\ndocker compose up --scale \"web=${REPLICAS:-1}\"","handlingStrategy":"validation","validationCode":"# bash: validate SERVICE=NUM before compose sees it\nfor s in \"${SCALE_ARGS[@]}\"; do\n  [[ \"$s\" =~ ^[^=]+=[0-9]+$ ]] || { echo \"bad --scale '$s' (want SERVICE=NUM)\" >&2; exit 2; }\ndone\ndocker compose up \"${SCALE_ARGS[@]/#/--scale }\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always default replica counts: ${REPLICAS:-1}.","One --scale flag per service; never a comma-separated list."],"tags":["cli","scale","flags","validation","parsing"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}