|
|
楼主 |
发表于 2018-6-21 15:15:42
|
显示全部楼层
报错内容:Failed to get D-Bus connection: Operation not permitted。2 Z7 j$ d7 p4 O+ C- S0 e4 M' g
* ^! F5 Y, X1 u4 i" J, a
报这个错的原因是dbus-daemon没能启动。systemctl并不是不能使用。将CMD或者entrypoint设置为/usr/sbin/init即可。docker容器会自动将dbus等服务启动起来。如下:8 h$ ]6 N9 o2 ]) [0 P5 ^6 ]* w
docker run --privileged -ti --name test docker.io/centos:7 /usr/sbin/init
$ R4 D( r5 G9 k' x
* M; Z0 ?% W; y% ^$ ]# docker run --privileged -ti --name centos7.2 docker.io/centos:7 /usr/sbin/init, P1 }& x: K: m& H
Unable to find image 'centos:7' locally
1 k, a: f; N; |0 ]7: Pulling from library/centos
- g/ c5 {# M* i4 S- Z y! z7dc0dca2b151: Pull complete
4 A1 s# k9 A7 G' O% DDigest: sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa53226 }9 p, }* T: E4 @9 h* G
Status: Downloaded newer image for centos:71 S; F, p& A1 |7 R+ A
+ e K: ?2 ~( F! ?& R% y
# 在创建docker容器时添加--privileged
. y$ ?) i5 a( ^docker run --privileged -ti -e "container=docker" -v /sys/fs/cgroup:/sys/fs/cgroup centos /usr/sbin/init q8 c! i1 A! [& k- H/ t" s( K
|
|