docker commit`在使用`/ sbin / init`时失败

我知道我知道。 我想知道,想要在一个容器中访问servicectl是不好的!

现在这是在我们后面,我有一个问题。 当我做这样的事情时:

 docker run -P --privileged --net=host --cidfile="/path/to/file.cid" -t -i --oom-kill-disable myimage /sbin/init 

我做了一些东西,想要使用这个命令:

 docker commit -m 'Install This, configure that' 133c myimage 

命令行等待,等待。 在磁盘上没有写入,处理器和RAM上没有太多活动。 如果我尝试docker ps ,terminal也冻结(我的意思是,即使CTRL + C将无法正常工作)。

但是,如果我改变了第一个命令

 docker run -P --privileged --net=host --cidfile="/path/to/file.cid" -t -i --oom-kill-disable /bin/bash 

我做了相同的修改,然后提交,它工作得很好(但由于D-Bus问题,我不能重新启动任何东西)。

该容器在CentOS 7.2映像上,在CentOS主机和Ubuntu主机上遇到同样的问题。

使用centos / systemd基本映像,它包含systemd rpm。 而不是在centos7基本映像systemd-containerfind特殊的systemd-container

https://hub.docker.com/r/centos/systemd/

然后cgroup卷是必需的

  docker run --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro centos:systemd