Skip to content

fix: support --memory-swap and --memory-swappiness in docker service update - #7130

Open
waterWang wants to merge 1 commit into
docker:masterfrom
waterWang:master
Open

fix: support --memory-swap and --memory-swappiness in docker service update#7130
waterWang wants to merge 1 commit into
docker:masterfrom
waterWang:master

Conversation

@waterWang

Copy link
Copy Markdown

Description

The --memory-swap and --memory-swappiness flags are handled by docker service create but are missing from the update path in updateService(). This causes docker service update --memory-swap '1G' to silently ignore the option, leaving the service's SwapBytes unchanged.

Reproduction

  1. Create a service with a memory limit: docker service create --limit-memory '0.5G' --memory-swap '0.5G' ubuntu tail -f /dev/null
  2. Verify SwapBytes: docker service inspect <id> --format '{{.Spec.TaskTemplate.Resources.SwapBytes}}' → 536870912
  3. Attempt to update: docker service update <id> --memory-swap '1G' --force
  4. Check again: SwapBytes is still 536870912

Fix

Added flagSwapBytes and flagMemSwappiness handling to the updateService function in cli/command/service/update.go, matching the logic already present in resourceOptions.ToResourceRequirements() used by docker service create.

Fixes moby/moby#53196

Signed-off-by: waterWang waterWang@users.noreply.github.com

…update

The --memory-swap (flagSwapBytes) and --memory-swappiness
(flagMemSwappiness) flags were handled in docker service create
but missing from the update path in updateService(), causing
docker service update --memory-swap to silently ignore the option.

Fixes moby/moby#53196

Signed-off-by: waterWang <waterWang@users.noreply.github.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/command/service/update.go 0.00% 7 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@thaJeztah

Copy link
Copy Markdown
Member

It looks like the DCO check is failing;

Commit sha: 3bf7c8d, Author: waterWang, Committer: waterWang; Expected "waterWang water@users.noreply.github.com", but got "waterWang waterWang@users.noreply.github.com".

Can you;

  • amend the commit and use your real name and correct e-mail address (instead of your GitHub handle)
  • remove the Fixes moby/moby#53196 from the commit message; these tend to produce a lot of noise if commits gets merged or cherry-picked

(canned reply with more details below);


Thank you for contributing! It looks like your commit message is missing a DCO sign-off,
causing the DCO check to fail.

We require all commit messages to have a Signed-off-by line with your name
and e-mail (see "Sign your work"
in the CONTRIBUTING.md in this repository), which looks something like:

Signed-off-by: YourFirstName YourLastName <yourname@example.org>

There is no need to open a new pull request, but to fix this (and make CI pass),
you need to amend the commit(s) in this pull request, and "force push" the amended
commit.

Unfortunately, it's not possible to do so through GitHub's web UI, so this needs
to be done through the git commandline.

You can find some instructions in the output of the DCO check (which can be found
in the "checks" tab on this pull request), as well as in the Moby contributing guide.

Steps to do so "roughly" come down to:

  1. Set your name and e-mail in git's configuration:

    git config --global user.name "YourFirstName YourLastName"
    git config --global user.email "yourname@example.org"

    (Make sure to use your real name (not your GitHub username/handle) and e-mail)

  2. Clone your fork locally

  3. Check out the branch associated with this pull request

  4. Sign-off and amend the existing commit(s)

    git commit --amend --no-edit --signoff

    If your pull request contains multiple commits, either squash the commits (if
    needed) or sign-off each individual commit.

  5. Force push your branch to GitHub (using the --force or --force-with-lease flags) to update the pull request.

Let me know if you need help or more detailed instructions!

@waterWang

Copy link
Copy Markdown
Author

Hi maintainers, just a friendly ping — this PR has been open for a while. Could you take a look when you have a moment? Happy to address any feedback. Thanks!

@12joan

12joan commented Aug 2, 2026

Copy link
Copy Markdown

@waterWang Thanks for finding a fix for the issue I reported.

Happy to address any feedback. Thanks!

You were asked here to resolve issues related to DCO. From what I can gather, this is because your commit looked like this:

Author: waterWang <water@users.noreply.github.com>
Date:   Tue Jul 28 18:33:08 2026 +0800

    fix: support --memory-swap and --memory-swappiness in docker service update
    
    The --memory-swap (flagSwapBytes) and --memory-swappiness
    (flagMemSwappiness) flags were handled in docker service create
    but missing from the update path in updateService(), causing
    docker service update --memory-swap to silently ignore the option.
    
    Fixes moby/moby#53196
    
    Signed-off-by: waterWang <waterWang@users.noreply.github.com>

Notice that the email address associated with the commit begins with water@ but the sign-off uses waterWang@. I believe that was the cause of the failure. You were also asked to remove the Fixes moby/moby#53196 line from this commit message.

To resolve this, you'll need to change the email address configured with your local Git client to waterWang@users.noreply.github.com, recreate the commit locally, and then force push to this branch.

@12joan

12joan commented Aug 2, 2026

Copy link
Copy Markdown

@thaJeztah One issue I noticed with the canned reply is that it doesn't mention that including this line purportedly constitutes agreement to the Developer's Certificate of Origin 1.1.

This is stated in the CONTRIBUTING file linked in your reply, but since following this link isn't necessary to follow the instructions in the canned reply, many contributors will include the sign-off without being aware of its purported significance. In my opinion, this makes the validity of the sign-off as a legally valid signature very dubious.

Perhaps you should add a note to the canned reply, in bold and with a link to the DCO 1.1, saying explicitly that by calling git commit with the -s or --signoff flag or by including the sign-off manually, the developer agrees to the terms of that agreement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot modify --memory-swap using docker service update

4 participants