LXC Tips

最後更新: 2021-08-07

目錄

  • Kill hang container
  • Cleaning up LXC cgroups
  • Disable Container dmesg
  • Prevent process bombing
  • Change Password

Kill hang container

 

hang 的情況

lxc-start -n sshgw -F

output & hang

lxc-start: utils.c: safe_mount: 1653 Invalid argument
     - Failed to mount /sys/kernel/debug onto /usr/lib/x86_64-linux-gnu/lxc/sys/kernel/debug

kill it

ps aux | grep lxc-start

kill -9 ??

 


Cleaning up LXC cgroups (remove orphaned cgroups)

 

# U16

manually removing all the child cgroups underneath /sys/fs/cgroup/*/lxc/<container>

find /sys/fs/cgroup/*/lxc/sshgw/ -type d | tac | xargs rmdir

 


Disable Container dmesg

 

透過 seccomp 限制 Container

/usr/share/lxc/config/common.seccomp

syslog errno 1

 


Prevent process bombing

 

for performance reasons the kernel does not account kernel memory use

  unless a kernel memory limit is set.

(lxc.cgroup.memory.kmem.limit_in_bytes = number)

Checking

cat /sys/fs/cgroup/memory/memory.kmem.usage_in_bytes

cat /sys/fs/cgroup/memory/memory.kmem.limit_in_bytes

cat /sys/fs/cgroup/memory/memory.kmem.failcnt

cat /sys/fs/cgroup/memory/memory.kmem.tcp.*

 


Change Password

 

[方法1]

chroot myvps/rootfs

passwd

New password:
Retype new password:
passwd: Authentication token manipulation error
passwd: password unchanged

[方法2]

lxc-attach myvps