How to drop_caches inside a container?

Hello,
How to drop_caches inside a container?

on host
# lxc --version
2.0.9
# cat /etc/issue
Ubuntu 16.04.2 LTS

on guest (inside container)
# echo 3 > /proc/sys/vm/drop_caches
bash: /proc/sys/vm/drop_caches: Read-only file system

VM caches are global to the entire system, you can’t drop them for just a single container.
You need to do it as root on the host, which will then flush the cache for the entire system.

Hi, sorry to revive this thread (not sure if that’s against policy, but this reply didn’t seem worth a new thread)

I am working on an issue wherein the goal is to drop caches for a single container. As the last reply was 5 years ago, I was wondering if this has since changed in any way?

My situation is that I have two lxc containers, and we want the cgroups in one of them to drop all their caches (which is done using that echo command that the original poster listed) but not the cgroups in the other. I am not sure how to accomplish this and need ideas (any hacks?) or just a flat out answer that it isn’t possible.

It isn’t possible.

1 Like