随机命令挂起时如何修复 Centos lxc 容器?

How to fix Centos lxc containers when random commands are hanging?

宿主服务器为Centos 7.0.1406。我正在使用以下命令创建 lxc Centos 7.2.1511 容器:

lxc-create -n test-container -t /etc/lxc/templates/lxc-centos --lxcpath=/var/lib/lxc/ 

lxc 容器已创建,我可以像这样启动它并附加到它:

lxc-create -n test-container -t /etc/lxc/templates/lxc-centos --lxcpath=/var/lib/lxc/ 

lxc-start -d -n test-container

lxc-attach -n test-container

一旦我进入 test-container,我尝试 运行 运行dom 命令,例如 adduser fooyum install emacs,它们总是挂起这个:

$ adduser foobar

...

或者像这样:

Is this ok [y/N]: y Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : freetype-2.4.11-11.el7.x86_64
1/132 Installing : libICE-1.0.9-2.el7.x86_64
2/132 Installing : 2:libpng-1.5.13-7.el7_2.x86_64
3/132 Installing : libSM-1.2.2-2.el7.x86_64
4/132 Installing : libjpeg-turbo-1.2.90-5.el7.x86_64
5/132 Installing : atk-2.14.0-1.el7.x86_64
6/132 Installing : jasper-libs-1.900.1-29.el7.x86_64
7/132 Installing : 1:emacs-filesystem-24.3-18.el7.noarch
8/132 Installing : libthai-0.1.14-9.el7.x86_64
9/132 Installing : mesa-libglapi-10.6.5-3.20150824.el7.x86_64
10/132

...

一开始以为是包的问题,​​结果连adduser这样的命令都挂了。我尝试重新启动容器,使用 salt lxc 模块创建容器,更新主机上的内核,避免更新包,克隆容器,以及许多其他...

我运行没主意了,我打算切换到Debian容器,但我想知道以前是否有人遇到过类似的问题并且知道如何解决它。

这似乎是当前 centos 中 lxc 工具版本的错误:lxc-1.0.8-1.el7.x86_64

使用不同的工具,例如 libvirt,或者将 lxc 升级到最新的当前版本 1.1.5 可以解决问题。