简单讲就是不要用centos:7而要用centos:centos7.9.2009
一些小众的科研软件非常古老,兼容性极低,在较常用的ubuntu、manjaro、centos8下很难装,只能生活在docker中。但他们经常在服务器中开发更新的版本,有的时候服务器系统升级了,新版本的软件就不兼容原来旧的docker。就很烦。
最近想把官方的docker从sl6改到centos7,从而适应更新一点的软件。遇到了这样的问题:
Failed to get D-Bus connection: Operation not permitted
我从docker hub上pull了centos:7的镜像,由于不熟悉docker以及Dockerfile,所以只是在容器内部操作。使用的物理机是centos7的环境。
在使用cvmfs安装我需要的软件环境的过程中,需要开启一个叫做autofs的service,systemctl start autofs
之后,系统报错:
Failed to get D-Bus connection: Operation not permitted
这一报错在网上很容易查到,并且高度一致,都说是这个容器运行的权限不够,需要加上--privileged
或者--privileged=true
,并且运行/sbin/init
才行:
事由:通过 systemctl start crond 启动任务时报错,具体如下
Failed to get D-Bus connection: Operation not permitted
解决方法:
启动容器时指定参数 --privileged=true 并执行命令 /usr/sbin/init,完整如下docker run -d --privileged=true --name centos7 centos /usr/sbin/init
然后通过 docker exec -it centos7 /bin/bash 进入容器操作
——原文:https://blog.csdn.net/w_yunlong/article/details/76460997
但是这样的操作仍然不能解决我的问题。
如果将这个容器在MacOS上运行,会出现类似的问题,Job for ssh.service failed because the control process exited with error code
,总之autofs服务没办法正常启动。其他服务也是这样,例如sshd。
最后折腾很久,在犄角旮旯里找到了一篇博客,具体是哪一篇我记不得了,总之就是说这是Centos7这个版本的bug,去用Centos7.2的镜像就可以了。
干脆pull了centos:centos7.9.2009,发现问题解决了。。。