[lxc-users] command "free" show different values on host and container

Fajar A. Nugraha list at fajar.net
Mon Jun 26 10:00:13 UTC 2017


On Thu, Jun 1, 2017 at 11:42 PM, Denis Bozhok <kron at ostrovok.ru> wrote:

> Hello!
> There is some strange problem.
> When I'm typing "free" on the host, I've got a result:
>
> free -g
>               total        used        free      shared  buff/cache
> available
> Mem:            251          26          15           0         210
>   224
> Swap:             0           0           0
>
> But when I'm executing it inside the container on this host the result is
> different:
>
> free -g
>              total       used       free     shared    buffers     cached
> Mem:           251        234         17          0          0          0
> -/+ buffers/cache:        234         17
> Swap:            0          0          0
>
>
>

What were you expecting?

Short version: That is the correct behavior.

Long version:
By default, each container maintains its own process list (and mounts, and
network stack, and others. search for "linux namespaces" for details). The
host can see all processes, but each container can only see its own
processes.

Each container can be configured to either be able to use up-to-all
available host memory, or limited to a certain ammount using cgroup limits.
lxcfs provides a "fake" interface to some system files (e.g. /proc/meminfo)
so that "classic" tools (e.g. top, free) can show "sane" values depending
on their cgroup limits.

-- 
Fajar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20170626/f56b4a6d/attachment.html>


More information about the lxc-users mailing list