zoukankan      html  css  js  c++  java
  • Failed to get D-Bus connection: Operation not permitted

    通过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 ~]#

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

    作者:Federico Sun
    博客地址:https://www.cnblogs.com/Cherry-Linux
    座右铭:人总是这么痛苦吗?还是只有小时候这样?总是如此。
  • 相关阅读:
    Security Group: Domain Local, Global, 和Universal 有什么区别?
    如何在EXCEL中运行SQL查询?
    SharePoint中的图标icon配置
    STSADM 命令使用大全
    SharePoint中的诊断日志记录(也就是ULS)
    SharePoint incoming email的计划与配置
    CSV文件格式
    Builtin\administrators 与 Domain Admins 用户组的来历与区别
    SQL Alias 的配置和使用
    Windows平台上的环境变量
  • 原文地址:https://www.cnblogs.com/Cherry-Linux/p/6913191.html
Copyright © 2011-2022 走看看