In Chapter 1, Introduction to Linux Containers we saw how easy it is to limit process resources by either directly manipulating files in the cgroup hierarchy or using the userspace tools.
Similarly, LXC comes with tools that are just as straightforward and easy to use.
Let's start by setting up the available memory for a container to 512 MB:
root@ubuntu:~# lxc-cgroup -n hooks_container memory.limit_in_bytes 536870912 root@ubuntu:~#
We can verify that the new setting has been applied by directly inspecting the
memory cgroup for the container:
root@ubuntu:~# cat /sys/fs/cgroup/memory/lxc/hooks_container/memory.limit_in_bytes 536870912 root@ubuntu:~#
Changing the value only requires running the same command again. Let's change the available memory to 256 MB and inspect the container by attaching to it and running the free utility:
root@ubuntu:~# lxc-cgroup -n hooks_container memory.limit_in_bytes 268435456 root@ubuntu:~# cat /sys/fs/cgroup/memory...