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

最新文章

  1. Hyper-V无法文件拖拽解决方案~~~这次用一个取巧的方法架设一个FTP来访问某个磁盘,并方便的读写文件
  2. ABP总体介绍
  3. C# 定时器 Timers.Timer Forms.Timer
  4. jQuery图片轮播特效
  5. Singleton Design Pattern
  6. 【bzoj1455】罗马游戏 可并堆
  7. 【转】android的一些开源项目
  8. system函数的总结
  9. 不用第三个变量,将a,b两个值互换,会出现什么样的异常?
  10. memcached与.NET的融合使用2
  11. lorem ipsum text占位符
  12. Python的内置函数open()的注意事项
  13. Visual Studio 2017 单独启动MSDN帮助(Microsoft Help Viewer)的方法
  14. vscode设置出错, 无法自动补全
  15. 17秋 软件工程 团队第五次作业 Alpha Scrum1
  16. sass、less是什么,如何使用?
  17. myeclipse集成jdk、tomcat8、maven、svn
  18. FFmpeg(8)-打开音视频解码器,配置解码器上下文(avcodec_find_decoder()、avcodec_alloc_context3())
  19. React.js - 入门
  20. 【差分约束系统/DFS版SPFA】BZOJ3436-小K的农场

热门文章

  1. [AngularJS] $scope.$watch
  2. (剑指Offer)面试题9:斐波那契数列
  3. 最短路+状态压缩dp(旅行商问题)hdu-4568-Hunter
  4. UNIX网络编程读书笔记:基本UDP套接口编程
  5. 查找文件工具find
  6. Python——Shell编程关于Sha-Bang(#!)
  7. 文字选中的js实现
  8. vcs github gitlab git名词解释
  9. 【LeetCode】111. Minimum Depth of Binary Tree (2 solutions)
  10. FFmpeg 如何探测网络流格式/如何从内存中获取数据