通过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. css3将图片、内容换为灰色

    直接用filter属性-webkit-filter: grayscale(100%);-moz-filter: grayscale(100%);-ms-filter: grayscale(100%); ...

  2. luoguP1196(带权并查集)

    题目链接:https://www.luogu.org/problemnew/show/P1196 思路: 带权并查集.对每个结点,构造表示该结点的头结点,该结点距头结点的距离,该列的大小3个数组. 在 ...

  3. cdoj第13th校赛初赛A - AC Milan VS Juventus 【枚举】

    http://acm.uestc.edu.cn/#/contest/show/54 A - AC Milan VS Juventus Time Limit: 3000/1000MS (Java/Oth ...

  4. 安全运维 -- Linux服务器使用公私钥密匙证书登录

    环境:Ubuntu 16 前言 黑客遍地都是,ssh/pop3/ftp等爆破工具的流行让站长的日常运维工作量大大加重.Metasplot,Bruter等工具更是针对以上协议有专门 的破解方法,有字典破 ...

  5. centos7之iptables与firewalld

    保障数据的安全性是继保障数据的可用性之后最为重要的一项工作.防火墙作为公网 与内网之间的保护屏障,在保障数据的安全性方面起着至关重要的作用. firewalld与iptables iptables f ...

  6. 子类覆写的变量被private隐藏,强制转换方式通过子类访问父类的被覆写变量:

    import static java.lang.System.*; public class SuperParent{ public static void main(String[] args){ ...

  7. 757A Gotta Catch Em' All!

    A. Gotta Catch Em' All! time limit per test 1 second memory limit per test 256 megabytes input stand ...

  8. [BAT]远程执行或停止计划任务

    执行 schtasks /run /tn "IPADForAdvisor_QA_APITest" /s SZPCWIN2K801 /u msdomain1\jzhang6 /p j ...

  9. JDK和Eclipse的下载路径

    JDK http://www.oracle.com/technetwork/java/javase/downloads/index.html Eclipse http://www.eclipse.or ...

  10. 原型工具之团队协作: Axure VS Mockplus

    一款软件产品的诞生,必然会经历一个过程:需求分析.设计.开发.测试.上线.如此反复迭代.而设计阶段中,原型设计.制作.交流.审核.迭代,是软件设计和开发的重要保障. 简单的一段话,我们可以解读出很多隐 ...