Why lxc container doesn’t execute config files on /etc/sysctl.d

lxcsysctl

My host is Ubuntu 16.04.1 LTS with privileged container.

I want to disable ipv6 of container, so I created a config file on /etc/sysctl.d/60-disable-ipv6.conf, I have tried lxc-start and lxc-stop -r my container, container's ipv6 is not disabled until run sudo sysctl -p /etc/sysctl.d/60-disable-ipv6.conf, it works, ipv6 address is disabled.

Why container doesn't load /etc/sysctl.d/*.conf?

Best Answer

Thnaks Phillip's instruction, I found systemd-sysctl.service didn't start in container with this message: ConditionPathIsReadWrite=/proc/sys/ was not met

I have tried lxc.mount.auto=proc and lxc.mount.auto=proc:rw in lxc config, but it doesn't work for me.

Last I found there is an issue of systemd:https://github.com/systemd/systemd/issues/4370, maybe if I could install systemd v232 it solves.(modify systemd-sysctl.service: ConditionPathIsReadWrite to /proc/sys/net could solve it.)

I added sudo sysctl --system on a start up script, it works.

Related Topic