Running lxcfs inside docker container

Hello Everyone,

Well I am new to this forum and new to the lxcfs too and I am trying to use the lxcfs inside my docker-based container. I am expecting lxcfs to help provide me with correct information on the uptime and other container-specific information.

I am able to run the lxcfs (4.0.8) inside my container and I can see all values inside /var/lib/lxcfs/proc but when I invoke the uptime command, it shows me the uptime of my VM.

I am not able to specify the mount point of /var/lib/lxcfs/proc/uptime to /proc/uptime in my container manifest file it throws an error while starting the container. And the container hangs if I am performing the mount bind as follows:
mount -B /var/lib/lxcfs/proc/uptime /proc/uptime

Kindly suggest the right way to configure the lxcfs inside a docker container.


Hi @connectrajeev

have you taken a look on ?

And yes, you don’t need to run lxcfs inside the container. You need to run lxcfs outside of the container and then use bindmounts.

1 Like

Thanks, @amikhalitsyn
It is my bad, I was somehow under the impression that lxcfs should be run inside the container and I was trying that. But, now I have corrected it now and run the lxcfs on my host VM and mount the lxcfs mounted fuse inside my docker container.

After this, I see the uptime & free commands are returning the correct values but I noticed /proc/cpuinfo still shows all CPUs info available on my host VM. I have used --cpuset-cpus while creating my docker container and allotted 1,2 CPUs to my container, so I am expecting on the docker shell I should see only 2 CPU info in /proc/cpuinfo

Can you please tell me, why it is not working as expected, am I doing anything wrong?


no, that’s correct behavior.

But if you really want to limit number of the CPU cores those are shown in /proc/cpuinfo you can run lxcfs with the --enable-cfs parameter. This should help.

Thanks for your response. Well, --enable-cfs is not helping, I still see the docker container is showing all CPU info in /proc/cpuinfo

in some cases it may not work:

if (cgroup_ops->can_use_cpuview(cgroup_ops) && opts && opts->use_cfs)
static bool cgfsng_can_use_cpuview(struct cgroup_ops *ops)
	struct hierarchy *cpu, *cpuacct;

	if (pure_unified_layout(ops))
		return true;

	cpu = ops->get_hierarchy(ops, "cpu");
	if (!cpu || is_unified_hierarchy(cpu))
		return false;

	cpuacct = ops->get_hierarchy(ops, "cpuacct");
	if (!cpuacct || is_unified_hierarchy(cpuacct))
		return false;

	return true;

In pure cgroup-v2 environment it will not work. That’s not a bug.

Can be useful to read:

Thanks for your response. I am using the cgroup-v1 environment. Can you please suggest, what can I do to fix the cpu & cpuacct related information on my containers? Is there a workaround/solution to fix it?

sure, but please describe your configuration.

  • docker container configuration
  • LXCFS command line options
  • what exactly isn’t working properly for you