Failed to get D-Bus connection: Operation not permitted

通过centos7镜像创建了一个docker容器,并在容器中安装了一个apache服务,但是启动时发生如下报错

[[email protected] ~]# rpm -qa | grep httpd
httpd-tools-2.4.6-45.el7.centos.4.x86_64
httpd-2.4.6-45.el7.centos.4.x86_64
[[email protected] ~]# systemctl start httpd
Failed to get D-Bus connection: Operation not permitted

出现此报错的原因网络上解释说这是centos7容器的一个BUG,就是会在systemctl 启动服务时出现报错,此BUG将在centos7.2中得到解决。

解决措施如下:

sudo docker run -it --privileged centos /usr/sbin/init    在启动docker容器时使用这种方式启动,使用中方式启动的弊端是等待过程可能要很长

# federico @ linux in ~ [15:30:07] C:1
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b255e96e1160 centos "/usr/sbin/init" 22 minutes ago Up 16 minutes agitated_hypatia
48082e41ebc5 centos "/bin/bash" About an hour ago Up About an hour pensive_lamport
1346963c2247 centos "/bin/bash" About an hour ago Up About an hour drunk_panini
ecb92e4f8374 centos "/bin/bash" About an hour ago Up About an hour suspicious_thompson

# federico @ linux in ~ [15:30:12]
$ sudo docker stop b255e96e1160
b255e96e1160

# federico @ linux in ~ [15:32:14]
$ sudo docker start b255e96e1160
b255e96e1160

在实验过程中,我们可能不想浪费太多的时间,所以在这里我们打开一个新的终端将这个容器重启(关闭->打开)

# federico @ linux in ~ [15:33:10]
$ sudo docker exec -it b255e96e1160 /bin/bash

docker自1.3版本起,提供了一个更加方便的工具exec,可以直接在容器中运行命令,例如我们使用我们刚刚新建的容器直接运行一个/bin/bash终端

[[email protected] ~]# yum -y install net-tools httpd vim

执行此命令安装我们所需的软件包

[[email protected] ~]# systemctl start httpd
[[email protected] ~]# netstat -antp | grep 80
tcp6 0 0 :::80 :::* LISTEN 139/httpd
[[email protected] ~]# ps aux | grep httpd
root 139 0.0 0.0 221944 7488 ? Ss 07:39 0:00 /usr/sbin/httpd -DFOREGROUND
apache 140 0.0 0.0 221944 5900 ? S 07:39 0:00 /usr/sbin/httpd -DFOREGROUND
apache 141 0.0 0.0 221944 5900 ? S 07:39 0:00 /usr/sbin/httpd -DFOREGROUND
apache 142 0.0 0.0 221944 5900 ? S 07:39 0:00 /usr/sbin/httpd -DFOREGROUND
apache 143 0.0 0.0 221944 5900 ? S 07:39 0:00 /usr/sbin/httpd -DFOREGROUND
apache 144 0.0 0.0 221944 5900 ? S 07:39 0:00 /usr/sbin/httpd -DFOREGROUND
root 148 0.0 0.0 9040 804 ? S+ 07:40 0:00 grep --color=auto httpd
[[email protected] ~]#

现在,我们遇到的问题已经得到了解决,但是笔者到现在还不知道有没有更好的办法,能够在不用新建容器的情况下解决此问题,如果有前辈了解,望不吝告知谢谢!

时间: 2024-08-03 21:14:07

Failed to get D-Bus connection: Operation not permitted的相关文章

docker容器中启动service服务 Failed to get D-Bus connection: Operation not permitted

解决方案: 启动时设置参数  --privileged 使用该参数,container内的root拥有真正的root权限.否则,container内的root只是外部的一个普通用户权限

Mac OS中, android stuido升级提示Connection failed. Please check your network connection and try again

在Mac系统中,安装android studio的正式版本是1.01的 如果直接在界面中点击check update,会弹出如下提示 Connection failed. Please check your network connection and try again 网传的一些方法过于繁琐,有一个临时替代的解决方案如下 1. Finder里, shift+command+g, 进入如下文件夹 /Applications/Android Studio.app/Contents/bin/stu

Yii “CDbConnection failed to open the DB connection: could not find driver"解决办法

前言:用Yii框架做项目时,有时会遇到“CDbConnection failed to open the DB connection: could not find driver”这个问题,这个问题通常是因为没有加载pdo_mysql.dll扩展所致.查找问题和解决的方法如下: 一.在phpinfo中查看是否有pdo_mysql模块或者在cmd中输入php -m查看是否加载了pdo_mysql模块. 二.要是在第一步中没有找到pdo_mysql模块,接着就是在php.ini中把extension

adb remount 失败:remount failed: Operation not permitted

adb remount 失败:remount failed: Operation not permitted 关于ADB的使用,这里再说明下:常用命令 adb shell - 登录设备shell,后面也可直接跟运行命令.如:adb shell rm -r /system/sd/app adb pull - 从手机中下载文件到电脑上.如:adb pull /data/app_s/Stock.apk C:\\Stock.apk adb push - 从电脑中上传文件到手机上.如:adb push C

安装Chive提示CDbConnection failed to open the DB connection.

最近初学PHP,看到Chive这个好玩的数据库管理工具,在登录时遇到这样的错误提示信息: CDbConnection failed to open the DB connection. 我的PHP版本是php-5.3.10 只需修改php安装目录下的php.ini中的 extension=php_pdo_mysql.dll 把前面的分号去掉即可 发现php还是挺有意思的,以前一直以为只学一门语言就可以了,外面的风景还是很精彩哒! 安装Chive提示CDbConnection failed to

CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

连接mysql出错:CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES) 注意这里的 'root'@'localhost' ,当检查登录用户和登录密码均没有错误的情况下,可以到 mysql.user 表中查看,User列中是否有 root用户:同时还要注意Host列,注意,这个字段是

yii框架:CDbConnection failed to open the DB connection: could not find driver的解决办法

这个问题是因为php中缺少pdo mysql造成的.解决方法是为php添加此扩展.前往你最早的php安装文件,进入ext/pdo_mysql/目录下,然后./configure --with-php-config=/home/work/service/php_for_apache2/bin/php-config --with-pdo-mysql=/home/work/service/mysql 然后make make install,然后屏幕上会提示pdo库安装到的路径,把此路径记下来然后添加到

使用phpmailer插件发邮件失败提示:SMTP -> ERROR: Failed to connect to server: Connection timed out (110) smtp connect() failed;

一个邮件发送问题,整整弄了我一周时间,起因是这样的,之前弄的一个网站,需要在邮箱里面认证之后才可以注册成功.网站上线了差不多一年之后,客户突然跟我说,网站不能注册了,然后我就查看了一下代码. 发现报这个错误:SMTP -> ERROR: Failed to connect to server: Connection timed out (110)   smtp connect() failed: 这是我的配置. 然后我就想,之前都是可以用的,那会不会可能是客户在邮箱里面更改客户端密码呢?然后我就

硬链接:ln: failed to create hard link `link1' => `1.txt': Operation not permitted提示

[已解决]硬链接:ln: failed to create hard link `link1' => `1.txt': Operation not permitted 软连接:ln: failed to create symbolic link `link1': Operation not supported [环境]VmWare的Linux + Windows 7 文件共享 [问题]在编译VMware下的Linux系统对从Windows中共享过来的文件 进行硬链接编译的时候,遇到:ln: fa