11

I have memswap_limit in my docker-compose file (version 2) and I want to change my docker-compose file on version 3. But I don't found how to replace memswap_limit.

I saw advices like "To configure resource constraints. This replaces the older resource constraint options in Compose files prior to version 3 (cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit)."

My docker-compose.yml file (version 2)

db: image: postgres:alpine mem_limit: 512m memswap_limit: 512m

  • 1
    See: https://stackoverflow.com/q/42345235/758446 – BlackVegetable Apr 11 '18 at 19:55
  • 2
    @BlackVegetable What do you mean? It doesn't mention `memswap_limit` there. – Ryan Jul 14 '18 at 16:06
  • Ah, it gives an example of how to do this going forward. You can no longer supply the `memswap_limit` directly. I was not advocating it as a duplicate, just as a helpful reference. – BlackVegetable Jul 16 '18 at 16:16
  • The problem is not inability to supply `memswap_limit` directly, but inability to supply it in any way at all. The linked question and its answers do not help in any way on how to do this going forward. – Anton Strogonoff Jan 11 '23 at 21:31

2 Answers2

3

Agree with @BlackVegetable. After updating to V3 memswap_limit is no longer there, people submitted ticket to docker github, hopefully it would bring it back. I just did a little investigation and it is still unsupported.

For now maybe be aware of there would be swap memory and inspect docker container, which would show you the memory and swap memory

From Docker website:

If --memory-swap is unset, and --memory is set, the container can use twice as much swap as the --memory setting, if the host container has swap memory configured. For instance, if --memory="300m" and --memory-swap is not set, the container can use 300m of memory and 600m of swap.

Or you can do the docker run command instead of the docker compose.

Daisy QL
  • 396
  • 3
  • 13
-2

Looking at this(https://docs.docker.com/compose/compose-file/compose-versioning/#version-2x-to-3x), there is a new resources section in v3 with "memory" combining older mem_limit and memswap_limit.

Sreeni
  • 748
  • 5
  • 6