Docker中使用systemctl启动服务报错的解决办法

简介: docker版本:[root@localhost gae_proxy]# docker versionClient: Version:        1.

docker版本:

[root@localhost gae_proxy]# docker version

Client:

Version:        1.10.3

API version:    1.22 Package version: docker-common-1.10.3-46.el7.centos.10.x86_64

Go version:      go1.6.3

Git commit:      d381c64-unsupported

Built:          Thu Aug  4 13:21:17 2016 OS/Arch:        linux/amd64

Server:

Version:        1.10.3

API version:    1.22 Package version: docker-common-1.10.3-46.el7.centos.10.x86_64

Go version:      go1.6.3

Git commit:      d381c64-unsupported

Built:          Thu Aug  4 13:21:17 2016 OS/Arch:        linux/amd64

镜像版本

[root@b2ca5610d3da /]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

    在docker中通过systemctl 启动服务的时候总是报Failed to get D-Bus connection: Operation not permitted 这样的错误提示。

[root@25d27693a24d ~]# systemctl start sshd

FailedtogetD-Busconnection: Operation not permitted

    解决办法就是在docker run 的时候运行/usr/sbin/init 。比如:

[root@localhost /]# docker run -tid --name hadoopbase centos/hadoopbase:v001 /usr/sbin/init

这样运行起来的container就可以使用systemctl来启动服务了,有的人说在CentOS7.2中解决了通过systemctl运行报错的问题,但是我在实际操作中还是遇到这样的问题。

    还有一种解决办法,就是在通过Dockerfile生成镜像文件的时候,通过CMD来执行/usr/sbin/init这条命令,即:CMD [ "/usr/sbin/init"];

参考:https://github.com/docker/docker/issues/7459 

https://github.com/docker/docker/issues/2296

目录
相关文章
|
16天前
|
Linux Docker 容器
安装docker-18.06报错Error: libseccomp conflicts with docker-18.06
通过这些步骤,您可以成功在CentOS上安装Docker 18.06,并解决libseccomp的冲突问题。这些方法确保系统兼容性,并保证Docker的正常运行。
54 27
|
24天前
|
Linux Docker 容器
Linux 中停止 Docker 服务报 warning 导致无法彻底停止问题如何解决?
在 Linux 系统中,停止 Docker 服务时遇到警告无法彻底停止的问题,可以通过系统管理工具停止服务、强制终止相关进程、检查系统资源和依赖关系、以及重置 Docker 环境来解决。通过以上步骤,能够有效地排查和解决 Docker 服务停止不彻底的问题,确保系统的稳定运行。
108 19
|
2月前
|
Ubuntu Linux Shell
(已解决)Linux环境—bash: wget: command not found; Docker pull报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled
(已成功解决)Linux环境报错—bash: wget: command not found;常见Linux发行版本,Linux中yum、rpm、apt-get、wget的区别;Docker pull报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled
485 68
(已解决)Linux环境—bash: wget: command not found; Docker pull报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled
|
4月前
|
负载均衡 应用服务中间件 网络安全
docker swarm添加更多的服务
【10月更文挑战第16天】
57 6
|
4月前
|
Docker 容器
docker swarm启动服务并连接到网络
【10月更文挑战第16天】
79 5
|
4月前
|
负载均衡 网络协议 关系型数据库
docker swarm 使用网络启动服务
【10月更文挑战第15天】
63 4
|
4月前
|
Docker 容器
docker swarm 在服务中使用网络
【10月更文挑战第14天】
95 2
|
4月前
|
JavaScript 前端开发 Docker
拿下奇怪的前端报错(二):nvm不可用报错`GLIBC_2.27‘‘GLIBCXX_3.4.20‘not Found?+ 使用docker构建多个前端项目实践
本文介绍了在多版本Node.js环境中使用nvm进行版本管理和遇到的问题,以及通过Docker化构建流程来解决兼容性问题的方法。文中详细描述了构建Docker镜像、启动临时容器复制构建产物的具体步骤,有效解决了不同项目对Node.js版本的不同需求。
184 0
|
4月前
|
网络虚拟化 Docker 容器
docker Desktop报错 error pulling image configuration 处理
docker Desktop报错 error pulling image configuration 处理
84 0
|
4月前
|
网络安全 Docker 容器
【Bug修复】秒杀服务器异常,轻松恢复网站访问--从防火墙到Docker服务的全面解析
【Bug修复】秒杀服务器异常,轻松恢复网站访问--从防火墙到Docker服务的全面解析
228 0