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 ...
随机推荐
- JZOJ 5353. 【NOIP2017提高A组模拟9.9】村通网
题目 为了加快社会主义现代化,建设新农村,农夫约(Farmer Jo)决定给农庄里每座建筑都连上互联网,方便未来随时随地网购农药. 他的农庄很大,有N 座建筑,但地理位置偏僻,网络信号很差. 一座建筑 ...
- MySQL单节点变更为主从节点
环境说明: 操作系统:CentOS 7.6 数据库版本:5.7 为了实验方便,同一台主机部署了两个实例,3306.3307 部署方案可参考 MySQL多实例部署:mysql多实例部署 - 太阳的阳ฅ ...
- 关于浏览器缓存造成的bug解决方法(页面跳转缓存,刷新生效)
1.在执行操作时带上一个随机数/时间戳,表示每一次的都是独一无二的
- 四大组件之活动Activity
什么是Activity? Activity是什么呢?翻译为"活动"!之所以叫它Activity是因为它用于跟用户交互的,所以就有了"活动"的翻译,官方的解释如下 ...
- 【面试题】手写async await核心原理,再也不怕面试官问我async await原理
前言 async await 语法是 ES7出现的,是基于ES6的 promise和generator实现的 generator函数 在之前我专门讲个generator的使用与原理实现,大家没了解过的 ...
- JS 替代eval方法
- PageHelper大致逻辑
简单涉及以下几个类: PageHelper PageMethod PageParam PageInterceptor implement Interceptor PageHelperAutoC ...
- Python爬虫抓取图片(re模块处理正则表达式)
import os.path import re import requests if __name__ == '__main__': # 如果不存在该文件夹则进行创建 if not os.path. ...
- lucene入门&Solr
LUCENE 1. 学习计划 1.案例分析:什么是全文检索,如何实现全文检索 2.Lucene实现全文检索的流程 a) 创建索引 b) 查询索引 3.配置开发环境 4.创建索引库 5.查询索引库 6. ...
- docker创建etcd
创建docker-compose.yml version: "3.5" services: etcd: hostname: etcd image: bitnami/etcd:3 d ...