docker systemctl start报错: Failed to get D-Bus connection: Operation not permitted
转载自:https://blog.csdn.net/zhenliang8/article/details/78330658
最近使用docker部署ansible,安装ssh 遇到启动服务报错:Failed to get D-Bus connection: Operation not permitted

刚开始接触Docker的朋友,可能会遇到这么一个问题,使用centos7镜像创建容器后,在里面使用systemctl启动服务报错。针对这个报错,我们接下来就分析下!
# docker run -itd --name centos7 centos:7
# docker attach centos7
# yum install vsftpd
# systemctl start vsftpd
Failed to get D-Bus connection: Operation not permitted
不能启动服务,什么情况?
难道容器不能运行服务嘛!!!
答:
Docker的设计理念是在容器里面不运行后台服务,容器本身就是宿主机上的一个独立的主进程,也可以间接的理解为就是容器里运行服务的应用进程。一个容器的生命周期是围绕这个主进程存在的,所以正确的使用容器方法是将里面的服务运行在前台。
再说到systemd,这个套件已经成为主流Linux发行版(比如CentOS7、Ubuntu14+)默认的服务管理,取代了传统的SystemV风格服务管理。systemd维护系统服务程序,它需要特权去会访问Linux内核。而容器并不是一个完整的操作系统,只有一个文件系统,而且默认启动只是普通用户这样的权限访问Linux内核,也就是没有特权,所以自然就用不了!
因此,请遵守容器设计原则,一个容器里运行一个前台服务!
我就想这样运行,难道解决不了吗?
答:可以,以特权模式运行容器。
创建容器:
# docker run -d -name centos7 --privileged=true centos:7 /usr/sbin/init
进入容器:
# docker exec -it centos7 /bin/bash
这样可以使用systemctl启动服务了。
docker systemctl start报错: Failed to get D-Bus connection: Operation not permitted的更多相关文章
- 巨坑npm run dev 报错 终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build/css/add.p
Windows10环境 npm run dev 报错 终于找到正确答案 Error: EPERM: operation not permitted, open '/data/public/build ...
- Docker 运行容器 CentOS7 使用systemctl 启动报错 Failed to get D-Bus connection: Operation not permitted
原系统:Centos 7 Docker 版本:1.12.6 操作:安装并运行 Tomcat 问题:在创建好容器之后,并且进入系统运行启动tomcat [root@cd11558d3a22 /]# sy ...
- Docker 内pip安装package报错: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'
说来奇幻(对本菜来说, 经常遇到堪称奇幻的问题) 之前在docker里面各种安装都没问题, 也不知道什么引起的, 昨天晚上调试的时候卸载了一个包的版本,然后就安不上了. 宿主机安装依然各种流畅,唯独d ...
- docker安装完报错:Failed to start docker.service: Unit docker.service is masked
执行 systemctl start docker 报错 Failed to start docker.service: Unit docker.service is masked. 解决 syste ...
- 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 ...
- docker pull报错failed to register layer: Error processing tar file(exit status 1): open permission denied
近来在一个云主机上操作docker pull,报错如下: failed to register layer: Error processing ): open /etc/init.d/hwclock. ...
- libvirt启动报错Failed to start Virtualization daemon
libvirt启动报错Failed to start Virtualization daemon 1.启动libvirt的具体报错如下 [root@localhost IOS]# service li ...
- CentOS 7.2重启网络报错 Failed to start LSB: Bring up/down
CentOS 7.2重启网络报错 Failed to start LSB: Bring up/down 我的虚拟机原本有两块网卡,一块叫eno16777736,另一块叫eno5033674.本来是正常 ...
- docker启动容器报错 Unknown runtime specified nvidia.
启动docker容器时,报错 问题复现 当我启动一个容器时,运行以下命令: docker run --runtime=nvidia .... 后面一部分命令没写出来,此时报错的信息如下: docker ...
- 突然虚拟机无法联网解决办法,且报错Failed to start LSB: Bring up/down
使用sudo service network restart去启动网络时起不来 使用systemctl status network.service查看网络状态也是failed,且报错Failed t ...
随机推荐
- C# 时间各种格式
1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=curre ...
- 开发者进阶必备的9个Tips & Tricks!
优秀的开发人员市场前景是十分广阔的,但想找到一份理想的工作,仅有代码知识是不够的.优秀的工程师应该是一个终身学习者.问题的创造性解决者,着迷于整个软件世界.要成为一名优秀的开发者,应该具备哪些品质并做 ...
- HBase架构及读写流程
HBase架构: Client 访问HBase的接口并维护cache来加快对HBase的访问 Zookeeper 1.保证任何时候,集群中只有一个活跃master 2.存储所 ...
- RESTful风格与Spring注解
RESTfulL是一种网络应用程序的设计风格和开发方式,即接口请求方式和路径的一种风格. 普通风格: localhost:8080/add?a=1&b=2 RestFul风格: localho ...
- 【4】java之基础数据类型的包装类
一.认识包装类 java 在设计之初有一个基本原则:一切皆对象,一切的操作都基于对象,但是有一个矛盾,基本数据类型不是对象.为了符合于这种要求,最早使用人为的方式解决此问题,如下所示: class ...
- 解决html2canvas.js和pdf.js导出页面问题
最近在做项目时有这么一个需求,需要将当前html页面导出pdf到本地.由于之前是做过类似的功能的借助了两个插件分别是html2canvas.js和pdf.js,本以为是非常顺利就能完成的,实际在使用过 ...
- 修复gitlab权限(docker方式搭建)
docker exec -it gitlab update-permissions docker restart gitlab
- K8s存储之Volume、PV、PVC、SC
Volume Volume(存储卷)是Pod中能够被多个容器访问的共享目录.Kubernetes的Volume概念.用途和目的与Docker的Volume比较类似,但两者不能等价.首先,Kuberne ...
- el-input 使用 回车键会刷新页面的问题
使用el-input的时候,光标聚焦在输入框,按下回车,会刷新页面.这是因为当el-form表单中只有一个input时,按下回车建会自动触发页面的提交功能, 产生刷新页面的行为 解决办法 法一: fo ...
- ESModule导入
//导入某方法 import pick from "lodash/pick"; //默认导入方式 import { pick } from "lodash"; ...