Container swap usage on ZFS

Can someone please explain how the swap works inside containers? I would have thought that since the system resources are shared, shouldn’t the swap also be shared? Inside the container (ZFS based) using htop it says that swap isn’t being used even when the host has 32GB allocated.

The host has 64GB of RAM and 32GB of swap. I have 2 containers. One container is using 20GB of RAM and another 5. If one container used a lot of RAM, would the host automatically start swapping the containers processes, or would the processes inside the container die due to lack of RAM, or would the whole container die?


Also, is there any ideas as to why the host would be showing 49GB of RAM used in htop, when container 1 is using 5GB and container 2 is using 20GB? Nothing else is running.

Swap is global to the system, so containers will cause swapping eventually, doesn’t sound like your system is anywhere near reaching that point though.

As for the usage question, you’d need to look at the complete /proc/meminfo output to understand where the memory is going. It may just be used for caching. Also worth noting that ZFS is a very big user of memory for caching and that this does not report as “cached” but as used memory instead. So you’d want to separately look at the ARC usage.

Awesome, thanks for that @stgraber.

With the high RAM usage, the confusing part is that the host system is using ext4 while the container is using ZFS. The high RAM usage is reported on the host system and not in the container. Thanks for pointing me in the right direction, the container ZFS ARC is making use of the RAM.