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

目录
相关文章
|
6月前
|
Ubuntu Linux 网络安全
Ubuntu Docker镜像:支持systemctl、SSH、VNC
总的来说,创建一个支持systemctl、SSH和VNC的Ubuntu Docker镜像需要一些技术知识,但是通过学习和实践,我们可以掌握这些技术。这将使我们能够更有效地使用Docker,更好地管理我们的应用程序和服务。CentOS系统中的日志文件位置和管理
188 17
|
6月前
|
Ubuntu 安全 网络安全
Docker镜像:Ubuntu支持systemctl、SSH和VNC
总的来说,Docker提供了一个灵活且强大的方式来创建和运行自定义的Ubuntu镜像。通过理解和使用Dockerfile,你可以轻松地创建一个支持systemctl、SSH和VNC的Ubuntu镜像。
371 21
|
10月前
|
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
4639 69
(已解决)Linux环境—bash: wget: command not found; Docker pull报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled
|
8月前
|
Linux Docker 容器
安装docker-18.06报错Error: libseccomp conflicts with docker-18.06
通过这些步骤,您可以成功在CentOS上安装Docker 18.06,并解决libseccomp的冲突问题。这些方法确保系统兼容性,并保证Docker的正常运行。
213 27
|
8月前
|
NoSQL MongoDB 数据库
使用 docker 快速搭建开发环境的 mongodb 服务
本指南介绍如何使用 Docker 和 Docker Compose 部署 MongoDB 和 Mongo Express。首先,通过 Docker 命令分别启动 MongoDB(镜像 `mongo:7.0.14`)和 Mongo Express(镜像 `mongo-express:1.0.2-20-alpine3.19`),并配置环境变量确保两者能正确连接。接着,提供了一个 `docker-compose.yaml` 文件示例,包含 MongoDB 数据卷、健康检查及服务依赖配置,简化多容器管理。
1232 2
|
9月前
|
Linux Docker 容器
Linux 中停止 Docker 服务报 warning 导致无法彻底停止问题如何解决?
在 Linux 系统中,停止 Docker 服务时遇到警告无法彻底停止的问题,可以通过系统管理工具停止服务、强制终止相关进程、检查系统资源和依赖关系、以及重置 Docker 环境来解决。通过以上步骤,能够有效地排查和解决 Docker 服务停止不彻底的问题,确保系统的稳定运行。
609 19
|
12月前
|
负载均衡 应用服务中间件 网络安全
docker swarm添加更多的服务
【10月更文挑战第16天】
139 6
|
12月前
|
Docker 容器
docker swarm启动服务并连接到网络
【10月更文挑战第16天】
249 5
|
12月前
|
负载均衡 网络协议 关系型数据库
docker swarm 使用网络启动服务
【10月更文挑战第15天】
184 4
|
12月前
|
Docker 容器
docker swarm 在服务中使用网络
【10月更文挑战第14天】
254 2