找回密码
 注册
查看: 4685|回复: 3

配置centos7解决 docker Failed to get D-Bus connection 报错

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2018-6-21 15:55:21 | 显示全部楼层 |阅读模式
在创建docker时添加些参数:( W" j* l. a' k; s
   # docker run --privileged -ti  docker.io/centos:7 /usr/sbin/init &# Y: @# g' }1 B3 C! v; I
, u3 T) U. A  u1 C) ^8 q2 K9 D
Unable to find image 'centos:7' locally$ }  z4 p5 W- v
7: Pulling from library/centos2 e+ {3 L$ @3 b. }, i, D" @
7dc0dca2b151: Pull complete
0 m/ M/ C/ Q+ Y2 K+ D+ y; rDigest: sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa53220 w2 l" G- O  I! S0 D! G0 R
Status: Downloaded newer image for centos:78 w: t: B" t! T6 N" T' Q
& V  ]( s7 {3 r: S. R" Q9 ~1 t9 D

2 b  t3 u: D/ w+ G4 O8 A* A. B7 T; {6 j
# docker run --privileged -it centos /usr/sbin/init
( T9 i) I6 M4 r: m* j7 HUnable to find image 'centos:latest' locally
% y/ }  }2 X; a7 N1 L/ P/ Ulatest: Pulling from library/centos
% ^; q1 \$ I# c4 d* j# I6 _! p7dc0dca2b151: Pull complete 6 u0 J- \; m8 b. h, z# ^1 {
Digest: sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa5322
  a1 Y5 K& ?9 I  F) t! w! mStatus: Downloaded newer image for centos:latest8 }  I( @2 }* C( y
1 ^4 G3 `7 X4 R/ f
进入到docker容器中,安装httpd软件,并启动httpd服务。% W, m6 Z8 ], `, D- ~; d0 Q
# docker exec -it dcb5c79348a0 /bin/bash   M  g: m  D7 E0 Z

3 l0 D3 V: D8 E2 `[root@dcb5c79348a0 /]# systemctl start httpd2 N9 B' c8 d5 K7 f+ C3 J
[root@dcb5c79348a0 /]# systemctl status httpd.service2 [/ H7 `4 W4 y) y: i9 k
● httpd.service - The Apache HTTP Server
% t. h; y4 C/ ~0 A+ a* L   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)( c1 _! `! ~/ \
   Active: active (running) since Thu 2018-06-21 07:38:03 UTC; 11s ago
& m* z; f, y# J     Docs: man:httpd(8)
" [' J+ t% k0 F& B& s" i9 }" G2 ^           man:apachectl(8)8 L) |4 {' p( ~& G- d. @
Main PID: 199 (httpd)1 d$ r- v, }/ {, I* k. x
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"' N* }  k0 A% g* Y% J, M/ w) e# T" ]$ m
   CGroup: /docker/dcb5c79348a0ba92f0ccf225e2f9c42810b6f8ad7884400a968c767ae5569694/system.slice/httpd.service
- t* |8 _6 a3 ~3 |4 a* [           ├─199 /usr/sbin/httpd -DFOREGROUND
6 G4 D6 a2 ?2 r5 ]' T# [+ P           ├─200 /usr/sbin/httpd -DFOREGROUND
6 \' N) ^- e* L: N           ├─201 /usr/sbin/httpd -DFOREGROUND; Z4 B1 E( l8 b
           ├─202 /usr/sbin/httpd -DFOREGROUND
3 @3 P$ |: k' f% L4 Z7 T! J           ├─203 /usr/sbin/httpd -DFOREGROUND$ F8 e0 t- h" H9 h# }* }3 }& H0 ^
           └─204 /usr/sbin/httpd -DFOREGROUND+ v7 U: p0 H( l) c7 E$ F
           ‣ 199 /usr/sbin/httpd -DFOREGROUND  i0 L. n+ @. Q$ ~# T6 I9 h

% O& q' }' m. D3 o" O% |Jun 21 07:38:03 dcb5c79348a0 systemd[1]: Starting The Apache HTTP Server...  [4 ?+ F8 i. n; H
Jun 21 07:38:03 dcb5c79348a0 httpd[199]: AH00558: httpd: Could not reliably ...e; k9 d- u: v) l1 R& p
Jun 21 07:38:03 dcb5c79348a0 systemd[1]: Started The Apache HTTP Server.
2 u) s1 J8 k3 c: Z1 d. qHint: Some lines were ellipsized, use -l to show in full.
: C3 y5 u) \0 G& }

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2018-6-21 16:05:33 | 显示全部楼层
docker run  -it centos /usr/sbin/init &; O! X8 ?. S' g# d# _

4 A2 G% |: W1 O2 oStatus: Downloaded newer image for centos:latest) G2 x6 R) o) o8 X' ^9 @
Failed to mount tmpfs at /run: Operation not permitted4 I. T- j7 L$ c% V4 N, n
[!!!!!!] Failed to mount API filesystems, freezing.
( k; I) Q7 w' t$ u5 r1 c/ B" A- N
' `" \, ]' ]: F* j& f+ P, e$ a1 g$ d4 h3 E  o5 l5 P6 Z  Y" @: E/ u' A! \
[root@dockerserver ~]# docker exec -it 50b2bbf20091 /bin/bash
; O3 ^2 X' \* d" I6 V[root@50b2bbf20091 /]# yum install -y httpd7 D8 L3 r2 v, i! W

& {5 _, B3 w3 A) w0 s" f[root@50b2bbf20091 /]# systemctl start httpd.service& I* ]# V' U. o
Failed to get D-Bus connection: Operation not permitted# T6 I+ z# O  t  m  D, m

/ f* V8 |# M% y% c4 y+ o: e5 k2 C$ p: g% D% G
docker run --privileged -it centos /usr/sbin/init  &    #这样的方式建立的docker即可+ T' `+ ^; Q: X

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2018-6-21 16:10:09 | 显示全部楼层
[root@dockerserver ~]# docker ps -a9 d, B% l& S5 D: J
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
9 A( j/ o2 W8 W) ?% X, D50b2bbf20091        centos              "/usr/sbin/init"    4 minutes ago       Up 4 minutes                            distracted_bhabha
1 v  S5 [8 V" d  _" F[root@dockerserver ~]# docker stop 50b2bbf20091; k  P3 X0 e; z9 m  e% J
50b2bbf20091. {) w4 j4 l, K* T- j
[root@dockerserver ~]# docker rm 50b2bbf20091; C+ Y+ A9 c( D$ U+ [6 |8 j
50b2bbf20091
% S, I# r# g; t( ^. h/ j[root@dockerserver ~]# docker images
! t1 w' X3 h! {2 Z/ p  fREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
/ y6 h: [6 s! Q8 U8 b" r* `centos              latest              49f7960eb7e4        2 weeks ago         200MB2 c; t4 U- w7 R, S5 ?
5 y1 z- P+ x8 L# f5 q4 P/ D/ x3 f
4 P3 F2 F# _. w. j
[root@dockerserver ~]# docker rmi 49f7960eb7e4
' H+ v- I' }" A  J' eUntagged: centos:latest
5 `5 f0 J7 M, l* {3 V' c8 d" ?Untagged: centos@sha256:b67d21dfe609ddacf404589e04631d90a342921e81c40aeaf3391f6717fa53222 |* e) l0 p5 i; n
Deleted: sha256:49f7960eb7e4cb46f1a02c1f8174c6fac07ebf1eb6d8deffbcb5c695f1c9edd5: ^8 F( i5 F/ j: f, a6 ?
Deleted: sha256:bcc97fbfc9e1a709f0eb78c1da59caeb65f43dc32cd5deeb12b8c1784e5b8237! W: T, G5 C6 a9 F
1 H  P0 i. ~1 ]+ \7 W. W

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2018-6-21 16:10:34 | 显示全部楼层
[root@dockerserver ~]# docker images
  }/ I! W' T' N- g0 V3 xREPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
" B0 C3 b3 d3 H; P) z2 l2 }[root@dockerserver ~]# docker ps -a; ^5 O/ D3 l7 c9 k2 t1 I
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:30 , Processed in 0.037512 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表