LXC container shows host's full RAM amount and CPU count
Solution 1:
Currently the proc
filesystem is not "container aware" in mount namespaces, so tools basing their logic on this will get host-related values instead of container-related values.
But a work is in progess, it's called lxc-fs and few releases are available here. This is a user-space workaround that will make possible a bind mount over /proc
to get things consistent inside a container.
Solution 2:
There appears to be no way around it. LXC uses cgroups to do its RAM-limiting, and non-virtualization aware tools read stats like /proc/meminfo
which is not contained within LXC and will output the overall RAM in the system. You can see this behavior with free
or top
as well when run inside the container.
Source: http://fabiokung.com/2014/03/13/memory-inside-linux-containers/