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

[root@1346963c2247 ~]# 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
[root@1346963c2247 ~]# 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终端

[root@b255e96e1160 ~]# yum -y install net-tools httpd vim

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

[root@b255e96e1160 ~]# systemctl start httpd
[root@b255e96e1160 ~]# netstat -antp | grep 80
tcp6 0 0 :::80 :::* LISTEN 139/httpd
[root@b255e96e1160 ~]# 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
[root@b255e96e1160 ~]#

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

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

  1. Failed to get D-Bus connection: Operation not permitted解决

    docker中安装centos无法使用systemctl命令管理进程,报以下错误: Failed to get D-Bus connection: Operation not permitted 原因 ...

  2. docker—tomcat 报错:Failed to get D-Bus connection: Operation not permitted

    docker search centos   查系统镜像 docker pull docker.io/centos 进入容器 [root@git opt]# docker images REPOSIT ...

  3. Docker 运行容器 CentOS7 使用systemctl 启动报错 Failed to get D-Bus connection: Operation not permitted

    原系统:Centos 7 Docker 版本:1.12.6 操作:安装并运行 Tomcat 问题:在创建好容器之后,并且进入系统运行启动tomcat [root@cd11558d3a22 /]# sy ...

  4. 【Docker】Failed to get D-Bus connection: Operation not permitted解决

    ------------------------------------------------------------------------------------------------- | ...

  5. rsync同步时出现rsync: failed to set times on “xxxx”: Operation not permitted

    今天在同步数据的时候提示rsync: failed to set times on “xxxx”: Operation not permitted,一般来说要不是服务器时间不对或者权限没有设置好,下面 ...

  6. Centos D-Bus connection: Operation not permitted

    解决办法: 首先要先在后台启动一个 CentOS7 容器(注意不要少参数): docker run -d -e "container=docker" --privileged=tr ...

  7. remount failed: Operation not permitted ,怎么办呢?

    remount failed: Operation not permitted ,怎么办呢? 1. 确定是否正确连接手机了$ adb devices 2. 进入shell$ adb shell 3. ...

  8. zabbix: failed to accept an incoming connection

    错误描述 查日志发现: failed to accept an incoming connection: connection from "192.168.186.132" rej ...

  9. 【openstack报错】【metadata问题】‘http://169.254.169.254/2009-04-04/meta-data/instance-id’ failed : url error [[Errno 111] Connection refused]

    [时间]2014年2月25日 [平台]ubuntu 12.04.3 openstack havana  with nova-network in multi-host [日志]实例启动时输出的日志内容 ...

随机推荐

  1. python+webdriver,选取Select下拉框中的值

    在选择下拉框中的值时遇到了困难,用driver.find_element_by_id("").send_keys("")进行赋值不能成功获取下拉框中的值.   ...

  2. oracle杀掉执行的死循环存储过程

    select * from v$db_object_cache where locks > 0 and pins > 0 and type='PROCEDURE'; select b.si ...

  3. Java label

    标号label提供了一种简单的break语句所不能实现的控制循环的方法.当你嵌套在几层循环中想退出循环时,break只能退出一重循环,可以用标号标出想退出哪一个语句. 标号的命名不能以"_& ...

  4. vs2013和vs2010的配置

    win10下vs2013和vs2010的相关配置 ------made by siwuxie095 主要是推荐一些vs2013和vs2010的好用的插件和配色方案,下面主要是以vs2013示例 1.首 ...

  5. Asp.net实现同页面内多图片自动上传并带预览显示

    FileUpload控件实现单按钮图片自动上传并带预览显示 1.实现原理: 此方法适合针对有后台生成的图片相关内容,例如购物网站商品展示页面中的封面图片,图片的数量由后台访问数据库,并加载到页面.这种 ...

  6. Navicat Premium 12破解补丁

    Navicat Premium 12破解补丁是专门针对Navicat 12制作的一款破解工具,它可以帮助大家成功激活软件,激活后就可以免费使用软件所有功能了,小编亲测可用,有需要的可以下载试试. Na ...

  7. jq给动态生成的标签绑定事件的几种方法

    经常遇到给动态生成的标签绑定事件不好用,自己简单测试总结了下,结论如下了: body> <!-- 下面是用纯动态方式生成标签 --> <div id="d2" ...

  8. 解决ios手机页面overflow scroll滑动很卡的问题

    在移动端html中经常出现横向/纵向滚动的效果,但是在iPhone中滚动速度很慢,感觉不流畅,有种卡卡的感觉,但是在安卓设备上没有这种感觉; 要解决这个问题很简单: 一行代码搞定 -webkit-ov ...

  9. url传递数据

    一.post传递数据 $ci = curl_init($url); curl_setopt($ci, CURLOPT_HEADER, 0); curl_setopt($ci, CURLOPT_RETU ...

  10. 2017年值得一看的7个APP设计

    新媒体时代蓬勃发展,各类APP如雨后春笋般出现.下载到合适的APP,不仅衣食住行一键搞定,甚至健身.社交.阅读等需求也能足不出户地满足.对于广大“吃瓜群众”来说,选择APP是个人需求以及跟随潮流的选择 ...