docker:memory_limit
How to specify Memory & CPU limit in docker compose version 3
deploy: resources: limits: cpus: '0.001' memory: 50M reservations: cpus: '0.0001' memory: 20M
Swap
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 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 bothmemory
andmemswap_limit
must be set.memswap_limit
represents the total amount of memory and swap that can be used, andmemory
controls the amount used by non-swap memory. So ifmemory
=“300m” andmemswap_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 asmemory
, andmemory
is set to a positive integer, the container does not have access to swap. - If
memswap_limit
is unset, andmemory
is set, the container can use as much swap as thememory
setting, if the host container has swap memory configured. For instance, ifmemory
=“300m” andmemswap_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.
docker/memory_limit.txt · Last modified: 2024/05/07 17:14 by Denis Evsyukov