Skip to content

Conversation

@thaJeztah
Copy link
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)

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

@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 <[email protected]>
@thaJeztah thaJeztah force-pushed the swap_the_swappiness branch from 282839c to 75b7e23 Compare November 7, 2025 14:55
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@ndeloof ndeloof left a comment

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
Member Author

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
Contributor

ndeloof commented Nov 7, 2025

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

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

Labels

area/stack kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants