Not able to set ulimit ( max open files) inside vms

Hi ,

I am using lxd 3.8 in debian 9 . as we have a lot of issues regarding "max open files " value. I am tried to set ulimit to 65535 But inside vm its not happening .In the host I have set to 65535 and it remain same after restarting the host . but inside vm staill the value is 1024 .


If I am trying with ulimit -n command I am getting below error

bash: ulimit: open files: cannot modify limit: Operation not permitted

could anyone help me on this?


from your question it’s not clear if you used something like
lxc config set mycontainer limits.kernel.nofile (myvalue)
restarting the container after changing the value may help too.

Hi ,
I have tried that too but I am getting below error

root@cpu-bla:~# lxc config set vm635446 limits.kernel.nofile 1024
Error: Bad key: limits.kernel.nofile

works for me with lxd 3.13 and ubuntu 18.04
it should work as it was merged end of 2017 and lxd 3.8 released one year later. It probably means that your (hand compiled ?) debian 3.8 version is doing it wrong.

yeah i compliled manually in debian (lxc 3.8) is there any solution for this ?

yeah i compliled manually in debian (lxc 3.8) is there any solution for this ?

anyone help ???

Well, if I had to solve this, that is, if I had a customer wanting to pay me for solving this problems (very low probability :-)) I’d first check if the client has been well and truly compiled against the same version as the server, and if yes, I’d install same Debian version in KVM, install snap and snap lxd, check that if works, if not whine on LXD github issues, if yes try to compare behaviour of snap (working) version and compiled (not working) version, while also browsing at the LXD sources to try to understand, searching for similar issues on the internet, until the reason becomes clear or blood spill from my eyes.
If you want to live with source, you have to realize you can if not actually die, have at least, painful experiences with it.

To be clear…

When you say VMs… are you running LXD inside a VM (like kvm)?

Or when you say VM do you mean an LXD container?

@bmullan I am running lxd containers .

well you could be running lxd containers inside a VM … that’s why I asked just to be clear on where your problem was.

@bmullan my host system is a debian machnie not a VM .
I am running LXD containers in the host

When you try to set ulimit inside the container… how are you accessing the container?

Are you using ssh by chance?

Reason I am asking is, I believe ‘ulimit’ is a bash command like ‘cd’, and only root can execute it.

So if you are logging into the container using ssh as some other “user” than root you might need to use sudo to execute the command.

But if you are entering the container like:

$ lxc exec my_container bash

then you would already be “root” and so this would not be your problem but I thought I’d ask.

@bmullan I am accessing vm with lxc exec command

I don’t think you are right on this point. I routinely access my containers using ssh and have no problem with ulimit. Actually sometimes there are problems using ulimit as root in a container:

Anyway the OP says there are problems with using lxc config set, that’s before logging in the container.

is there any way to upgrade liblxc1 package in debian 9 ?
root@bla:~# lxc config set vmXXX limits.kernel.nofile 65535
error: Process limits require liblxc >= 2.1

getting above error ?

That explains it. You don’t need to install debian 9 in a KVM using snap and check for differences, if you did you’d find that snap lxc packages a more recent liblxc library with it allowing for lxd to work fully including lxc config set … nofile without this kind of hassle.
Works for me with ubuntu 16.04 hosts (16.04 packages liblxc 2.0 in system (deb) libraries).
Without snap you have to compile liblxc and support security updates yourself. That’s life for people wanting to compile system tools :slight_smile: