如何杀死卡住的 LXC 容器?

Oli*_*Oli 8 lxc

我有一个新的非特权 LXC 容器,我似乎无法停止。lxc-stop -n dl挂起。lxc-stop -k --nolock -n dl挂起。lxc-ls挂起。lxc-attach -n dl挂起。这个容器没有任何作用。

我已经重新启动lcxfs。所做的一切只是打乱了一个特权容器。这是这个容器的当前进程的样子(来自主机)。

lxc-start,24434
  ??systemd,24446 --system --deserialize 9
      ??agetty,25258 --noclear --keep-baud console 115200 38400 9600 vt220
      ??agetty,25846 --noclear --keep-baud pts/1 115200 38400 9600 vt220
      ??agetty,25878 --noclear --keep-baud pts/3 115200 38400 9600 vt220
      ??agetty,25906 --noclear --keep-baud pts/2 115200 38400 9600 vt220
      ??agetty,25934 --noclear --keep-baud pts/0 115200 38400 9600 vt220
      ??rsyslogd,26016 -n
      ?   ??{rsyslogd},26043
      ?   ??{rsyslogd},26044
      ??systemd-journal,25962
Run Code Online (Sandbox Code Playgroud)

该过程指出:

$ ps aux | grep -P '24434|24446|25258|25846|25878|25906|25934|25934|26016|26043|26044|25962'
oli      24434  0.0  0.0  43400  3552 ?        Ss   10:56   0:00 [lxc monitor] /home/oli/.local/share/lxc dl
100000   24446  0.0  0.1  36896  4972 ?        Ss   10:56   0:00 /lib/systemd/systemd --system --deserialize 9
100000   25258  0.0  0.0  15676  2504 pts/0    Ss+  10:56   0:00 /sbin/agetty --noclear --keep-baud console 115200 38400 9600 vt220
100000   25846  0.0  0.0  15676  2496 pts/1    Ss+  11:33   0:00 /sbin/agetty --noclear --keep-baud pts/1 115200 38400 9600 vt220
100000   25878  0.0  0.0  15676  2380 pts/3    Ss+  11:33   0:00 /sbin/agetty --noclear --keep-baud pts/3 115200 38400 9600 vt220
100000   25906  0.0  0.0  15676  2416 pts/2    Ss+  11:33   0:00 /sbin/agetty --noclear --keep-baud pts/2 115200 38400 9600 vt220
100000   25934  0.0  0.0  15676  2332 pts/0    Ss+  11:33   0:00 /sbin/agetty --noclear --keep-baud pts/0 115200 38400 9600 vt220
100000   25962  0.0  0.0  35256  3500 ?        Ss   11:33   0:00 /lib/systemd/systemd-journald
100104   26016  0.0  0.0 182640  3244 ?        Ssl  11:33   0:00 /usr/sbin/rsyslogd -n
Run Code Online (Sandbox Code Playgroud)

HRJ*_*HRJ 4

强制终止容器的systemd进程对我有用。

在你的例子中,

kill -9 24446
Run Code Online (Sandbox Code Playgroud)


ant*_*oPa 0

我保留此命令行以快速终止具有非常高 UID 的所有进程(位于我的容器中):

ps -ef | grep "^100[0-9][0-9][0-9]" | tr -s " " | cut -f2 -d " " | xargs -I {} kill -9 {}
Run Code Online (Sandbox Code Playgroud)

然后我就可以lxc-start再次使用了。

我还发现,lxc-stop当我使用lxc-start -d(在后台模式下)然后使用lxc-attach或连接时,问题较少ssh