Skip to content

cli/compose: memswap_limit -> memory_swap, mem_swappiness -> memory_swappiness - #6638

Open
thaJeztah wants to merge 1 commit into
docker:masterfrom
thaJeztah:swap_the_swappiness
Open

cli/compose: memswap_limit -> memory_swap, mem_swappiness -> memory_swappiness#6638
thaJeztah wants to merge 1 commit into
docker:masterfrom
thaJeztah:swap_the_swappiness

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

Align the names in the compose / stack schema with the command-line flags, instead of aligning with the existing options in the compose-schema (which I think originated from v1);
https://github.com/compose-spec/compose-spec/blob/a08f8d51631b7127ddac3d2c65537db429d0f1d0/spec.md?plain=1#L1440-L1461

- What I did

- How I did it

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztahthaJeztah added this to the 29.0.0 milestone Nov 7, 2025
@thaJeztahthaJeztah added status/2-code-review area/stack kind/refactor PR's that refactor, or clean-up code labels Nov 7, 2025
@thaJeztah

Copy link
Copy Markdown
MemberAuthor

@ndeloof I'm guessing the naming originated from what was already in the compose-spec at a different place;
https://github.com/compose-spec/compose-spec/blob/a08f8d51631b7127ddac3d2c65537db429d0f1d0/spec.md?plain=1#L1440-L1461

Would there be a motivation to align with those, or just go with this one?

## mem_swappiness`mem_swappiness` defines as a percentage, a value between 0 and 100, for the host kernel to swap out
anonymous memory pages used by a container.
-`0`: Turns off anonymous page swapping.
-`100`: Sets all anonymous pages as swappable.
The default value is platform specific.
## memswap_limit`memswap_limit` defines the amount of memory the container is allowed to swap to disk. This is a modifier
attribute that only has meaning if [`memory`](deploy.md#memory) is also set. Using swap lets the container write excess
memory requirements to disk when the container has exhausted all the memory that is available to it.
There is a performance penalty for applications that swap memory to disk often.
- If `memswap_limit` is set to a positive integer, then both `memory` and `memswap_limit` must be set. `memswap_limit` represents the total amount of memory and swap that can be used, and `memory` controls the amount used by non-swap memory. So if `memory`="300m" and `memswap_limit`="1g", the container can use 300m of memory and 700m (1g - 300m) swap.
- If `memswap_limit` is set to 0, the setting is ignored, and the value is treated as unset.
- If `memswap_limit` is set to the same value as `memory`, and `memory` is set to a positive integer, the container does not have access to swap.
- If `memswap_limit` is unset, and `memory` is set, the container can use as much swap as the `memory` setting, if the host container has swap memory configured. For instance, if `memory`="300m" and `memswap_limit` is not set, the container can use 600m in total of memory and swap.
- If `memswap_limit` is explicitly set to -1, the container is allowed to use unlimited swap, up to the amount available on the host system.

…wappiness
Align the names in the compose / stack schema with the command-line flags, instead
of aligning with the existing options in the compose-schema (which I think originated
from v1);
https://github.com/compose-spec/compose-spec/blob/a08f8d51631b7127ddac3d2c65537db429d0f1d0/spec.md?plain=1#L1440-L1461
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ndeloofndeloof left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing so would break backward compatibility with earlier compose files
Why change the compose file syntax, to align with flags just introduced and not yet release ? Those flags could be renamed to match existing compose attributes (introduced by docker/compose@d824cb9)

@thaJeztah

Copy link
Copy Markdown
MemberAuthor

The flags align with the ones on docker run, docker create

 -m, --memory bytes Memory limit
--memory-reservation bytes Memory soft limit
--memory-swap bytes Swap limit equal to memory plus swap: '-1' to enable
unlimited swap
--memory-swappiness int Tune container memory swappiness (0 to 100) (default -1)

And docker update;

 -m, --memory bytes Memory limit
--memory-reservation bytes Memory soft limit
--memory-swap bytes Swap limit equal to memory plus swap: -1 to enable unlimited swap

The new ones are on docker service create / docker service update;

 --memory-swap bytes Swap Bytes (-1 for unlimited)
--memory-swappiness int Tune memory swappiness (0-100), -1 to reset to default
(default -1)

@ndeloof

Copy link
Copy Markdown
Contributor

oh indeed, I guess it's to late to complain on docker/compose#2383 that the compose attribute should align with CLI flags 🥲

@dperny

Copy link
Copy Markdown
Contributor

Thanks, @thaJeztah, for doing this.

@thaJeztah

Copy link
Copy Markdown
MemberAuthor

Pending the discussion; we may need to go ahead with #6642 first, then move from there; would that be OK for you, @dperny ?

@thaJeztahthaJeztah modified the milestones: 29.0.0, 29.2.0Jan 13, 2026
@thaJeztahthaJeztah modified the milestones: 29.2.0, 29.3.0Jan 26, 2026
@thaJeztahthaJeztah modified the milestones: 29.3.0, 29.4.0Mar 4, 2026
@thaJeztahthaJeztah modified the milestones: 29.4.1, 29.5.0Apr 20, 2026
@thaJeztahthaJeztah modified the milestones: 29.5.0, 29.6.0May 7, 2026
@thaJeztahthaJeztah modified the milestones: 29.6.0, 29.7.0Jun 12, 2026
@vvolandvvoland modified the milestones: 29.7.0, 29.8.0Jul 30, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/stackkind/refactorPR's that refactor, or clean-up codestatus/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@thaJeztah@codecov-commenter@ndeloof@dperny@vvoland