Repository navigation
Conversation
Contributor
Author
|
The failing |
Add nerdctl compose scale SERVICE=REPLICAS..., like docker compose scale. Missing replicas are created and started in the background, and extra replicas are stopped and removed. --no-deps skips the dependencies of the scaled services, which UpOptions now supports through NoDeps. Leave the number of replicas out of the service hash: compose-go keeps it in deploy.replicas, so changing it with scale (or up --scale) recreated the replicas that were kept. Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
cvas22
force-pushed
the
feat/compose-scale
branch
from
October 29, 2026 04:16
7dc0ff5 to
f522715
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added
nerdctl compose scale, another Compose command still listed as unimplemented in the command reference (tracked in #3867).It follows
docker compose scale:nerdctl compose scale SERVICE=REPLICAS [SERVICE=REPLICAS...]sets the number of containers for each service.compose upwith the requested scale.svc-2andsvc-3aftersvc=1) are stopped and removed.compose up --scaledoesn't remove them, soScalecompares the service's containers with the replicas it should have and removes the rest.--no-depsskips the dependencies of the scaled services. I addedNoDepstoUpOptionsfor this, which passestypes.IgnoreDependenciestoForEachService. Nothing else sets it, socompose upis unchanged.Invalid arguments (
svc,svc=x,svc=-1) and unknown services are rejected before anything is created.Running it locally showed that scaling recreated the replicas that should have been kept:
scale web=1afterscale web=3re-createdweb-1.ServiceHashresetsscale, but compose-go v2 keeps the number of replicas indeploy.replicas, so the hash changed with every new count. This also happens onmainwithcompose up --scale. I madeServiceHashignoredeploy.replicas(on a copy, so the service config isn't modified). The hash of services that setdeploychanges once, so their containers are recreated on the firstupafter upgrading.Changes:
pkg/composer/scale.go:Composer.Scalepkg/composer/up.go:UpOptions.NoDepspkg/composer/config.go:ServiceHashignoresdeploy.replicascmd/nerdctl/compose/compose_scale.go: the command and argument parsingdocs/command-reference.md: documented the command and removed it from the unimplemented listNotes
I ran the tests locally, rootful, in a privileged container with nerdctl, containerd, runc, CNI and BuildKit built from this branch (
docker buildx build --target out-full):27 tests passed and 1 was skipped. I also ran it by hand (
dbandweb, wherewebdepends ondb; log lines about image checks trimmed):Rootless is only covered by CI. This is independent of #5300 (
compose wait), but both add a line to the same command list, so whichever merges second will need a trivial rebase.