docker Failed to get D-Bus connection 报错

在centos7的容器里面出现了一个BUG,就是serveice启动服务的时候出现报错,不能用service启动服务。
[root@e13c3d3802d0 /]# service httpd start
Redirecting to /bin/systemctl start  httpd.service
Failed to get D-Bus connection: Operation not permitted

首先恭喜你使用centos7镜像,然后就是不幸告诉你这个问题是个BUG 将在centos7.2解决。
  Currently, systemd in CentOS 7 has been removed and replaced with a fakesystemd package for dependency resolution. This is due to systemd requiring the CAP_SYS_ADMIN capability, as well as being able to read the host's cgroups. If you wish to replace the fakesystemd package and use systemd normally, please follow the steps below.
  
我查了好多地方都说是个BUG不能解决
有的说创建的时候加上 --privileged选项

我试了这些然而并没有任何的卵用

最后实在是没办法就 rpm -ql 软件包 查看安装的时候有哪些命令在PATH下,用这些命令去启动,这个是一种解决的方法
例如apache的启动就是用命令 httpd

这几天研究了个解决的办法比较靠谱,亲身实测好使:
systemctl start http.service
Failed to get D-Bus connection: No connection to service manager.

这个的原因是因为dbus-daemon没能启动。其实systemctl并不是不可以使用。将你的CMD或者entrypoint设置为/usr/sbin/init即可。会自动将dbus等服务启动起来。
   然后就可以使用systemctl了。命令如下:
   docker run --privileged  -ti -e "container=docker"  -v /sys/fs/cgroup:/sys/fs/cgroup  centos  /usr/sbin/init

Set environment variables (-e, --env, --env-file)

$ docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash

Use the -e--env, and --env-file flags to set simple (non-array) environment variables in the container you’re running, or overwrite variables that are defined in the Dockerfile of the image you’re running.

You can define the variable and its value when running the container:

$ docker run --env VAR1=value1 --env VAR2=value2 ubuntu env | grep VAR
VAR1=value1
VAR2=value2

docker Failed to get D-Bus connection 报错 docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash的更多相关文章

  1. Docker - 解决同步容器与主机时间报错:Error response from daemon: Error processing tar file(exit status 1): invalid symlink "/usr/share/zoneinfo/UTC" -> "../usr/share/zoneinfo/Asia/Shanghai"

    问题背景 这里讲解了如何同步容器和主机的时间:https://www.cnblogs.com/poloyy/p/13967532.html 其中使用方法二 docker cp /etc/localti ...

  2. wince6.0 编译报错:"error C2220: warning treated as error - no 'object' file generated"的解决办法

    内容提要:wince6.0编译报错:"error C2220: warning treated as error - no 'object' file generated" 原因是 ...

  3. mysql启动报错 mysql InnoDB: Error: could not open single-table tablespace file

    mysql启动不成功,报错 mysql InnoDB: Error: could not open single-table tablespace file innodb_force_recovery ...

  4. nagios监控客户端报错/usr/bin/perl^M: bad interpreter: No such file or directory

    nagios服务端监控客户端内存时发现监控不上 在客户端直接执行脚本,报错如下: # /usr/local/nagios/libexec/check_memory.pl -w 6% -c 3% -ba ...

  5. mysql报错“Starting MySQL...The server quit without updating PID file”处理

    http://blog.csdn.net/lzq123_1/article/details/51354179 注意:要将/usr/bin/mysql_install_db替换成 /usr/bin/my ...

  6. salt '*' state.highstate 报错找不到文件,环境如下No Top file or master_tops data matches found.

    salt '*' state.highstate 报错找不到文件,环境如下No Top file or master_tops data matches found. file_roots:    b ...

  7. 页面白屏并且报错PHP Parse error: syntax error, unexpected end of file in 试了很久总算解决了

    页面白屏并且报错PHP Parse error:  syntax error, unexpected end of file in 试了很久 啥短标记,打开,都试了 最简单的办法 是重新建立一个文件, ...

  8. 报错:ERROR! The server quit without updating PID file (/usr/local/var/mysql/chenyuntekiMacBook-Air.local.pid).

    在Mac上通过brew install mysql 安装了完mysql 执行mysql.server start 报错:ERROR! The server quit without updating ...

  9. 解决apscheduler报错:Run time of job …… next run at: ……)” was missed by

    在Django中使用apscheduler django_apscheduler 实现定时任务, 来完成数据拉取. 一段时间后发现数据量对不上,遂查日志 发现报错如下: Run time of job ...

随机推荐

  1. PHP如何使用免费在线客服插件

    1 你可以从以下网址下载http://www.hur.cn/Soft/2011/12448.html 2 解压并放到任意文件夹下 3 在安装之前,先在数据库中创建一个完整的数据库,因为待会儿安装完成之 ...

  2. Android单个进程内存分配策略

    android不同设备单个进程可用内存是不一样的,可以查看/system/build.prop文件. # This is a high density device with more memory, ...

  3. MySQL联合多表更新和删除

    多表更新 在 MySQL 3.23 中,你能够使用 LIMIT # 来确保仅仅有给定的记录行数目被更改. 假设一个 ORDER BY 子句被使用(从 MySQL 4.0.0 開始支持),记录行将以指定 ...

  4. JavaScript严格模式下this指向

    一般认为:严格模式下this不允许指向全局对象.是函数体是否处于严格模式! 如:http://www.ruanyifeng.com/blog/2013/01/javascript_strict_mod ...

  5. SQL server 2008里面通过sys.dm_exec_procedure_stats得到存储过程的执行信息--转

    --转自:http://blogs.msdn.com/b/apgcdsd/archive/2011/05/13/sql-server-2008-sys-dm-exec-procedure-stats. ...

  6. excel 截取单元格部分内容(从指定位置截取)

      excel 截取单元格部分内容(从指定位置截取) CreateTime--2018年5月28日08:28:46 Author:Marydon 1.情景展示 截取手机号后6位 2.实现 语法说明:r ...

  7. UI_storyboard实现页面回调

    新建类 注意继承关系 #import <UIKit/UIKit.h> @interface CustomPopIt : UIStoryboardSegue @end #import &qu ...

  8. asp.net MVC 视图文件(cshtml/vbhtml)变更编译过程示范

    更改cshtml文件的时候 并不会触发程序重新启动,而是进入了编译状态  csc.exe进程启动. 非阻塞的方式进行等待,延时等待. 示范程序:http://pan.baidu.com/s/1skDY ...

  9. hibernate+spring mvc, 解决hibernate 对象懒加载 json序列化问题

    引用地址 在使用Spring MVC时,@ResponseBody 注解的方法返回一个有懒加载对象的时候出现了异常,以登录为例: @RequestMapping("login") ...

  10. Android屏幕计量单位详解

    1.px (pixels)(像素):是屏幕的物理像素点,与密度相关,密度大了,单位面积上的px会比较多.通常不推荐使用这个. 2.dip或dp(与密度无关的像素):一个基于density的抽象单位,这 ...