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

简介: docker版本: [root@localhost gae_proxy]# docker version Client: 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

目录
相关文章
|
14天前
|
Kubernetes 网络协议 Linux
docker镜像仓库hub.docker.com无法访问-解决办法
docker镜像仓库hub.docker.com无法访问-解决办法1 个人镜像站点2 dockerhub为什么无法访问2.1 查看dockerhub实际IP2.2 ping检测3 镜像加速3.1 使用国内镜像加速3.1.1 docker配置:3.1.2 containerd配置:3.2 使用博主个人镜像仓库3.2.1 目前有如下镜像仓库,后续会陆续增加3.2.2 使用方式3.2.3 拉取镜像
64 3
docker镜像仓库hub.docker.com无法访问-解决办法
|
1月前
|
网络协议 应用服务中间件 Docker
docker启动容器报错iptables failed:....docker0: iptables: No chain/target/match by that name.
docker启动容器报错iptables failed:....docker0: iptables: No chain/target/match by that name.
|
1月前
|
运维 网络安全 Docker
docker报错ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule
docker报错ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule
|
2月前
|
Docker 容器
docker报错ERROR: for hass “host” network_mode is incompatible with port_bindings
docker报错ERROR: for hass “host” network_mode is incompatible with port_bindings
191 0
|
3月前
|
Docker 容器
docker 内执行 systemctl 报错 解决方案: Failed to get D-Bus connection: Operation not permitted
docker 内部安装 systemctl 工具包的路径非系统路径,拷贝到系统路径 /bin/ 目录下,并且给执行权限即可
148 1
|
3月前
|
关系型数据库 MySQL Docker
Docker报错 WARNING: IPv4 forwarding is disabled. Networking will not work
Docker报错 WARNING: IPv4 forwarding is disabled. Networking will not work
46 0
|
3月前
|
Linux Docker 容器
yum install docker报错:Another app is currently holding the yum lock
今天在centos7安装docker的时候yum报错。 在进程里查看下:ps -ef | grep update 把后台占用的更新进程杀掉。
42 0
|
3月前
|
关系型数据库 MySQL 数据库
mysql8.0 docker部署后连接报错caching_sha2_password could not be loaded
切记:一般情况下不建议使用容器方式部署数据库,此方式只是为了验证一些mysql8.0的特性,做学习和测试使用。
38 0
|
8月前
|
Ubuntu Linux Docker
解决办法:nvidia-docker2指定最新docker,而安装又找不到
解决办法:nvidia-docker2指定最新docker,而安装又找不到
277 0
LXJ
|
jenkins Shell 持续交付
Jenkins中Pipeline没有Docker执行权限解决办法
Jenkins中Pipeline没有Docker执行权限解决办法
LXJ
625 0
相关产品
云迁移中心
推荐文章
更多