微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法获得D-Bus连接:不允许进行操作[docker]

如何解决无法获得D-Bus连接:不允许进行操作[docker]

我正在尝试使用在其上运行Nginx Web服务器的泊坞窗映像(centos7)。我创建了一个Dockerfile,看起来像这样:

FROM centos:centos7

RUN yum update -y

# -------- OPENSSL -------- 

#ADD install-openssl.sh /
#RUN chmod +x install-openssl.sh
#RUN /install-openssl.sh

# -------- Nginx --------

RUN yum install epel-release -y
RUN yum install Nginx -y

# copy a configuration file from the current directory 
ADD Nginx.conf /etc/Nginx/

# Append "daemon off:" to the beginning of the configuration
RUN echo "daemon off;" >> /etc/Nginx/Nginx.conf

# Expose ports
EXPOSE 80

RUN systemctl start Nginx

我使用以下命令构建docker映像:

docker build -t Nginx-img .

我这样运行:

docker -v run --name Nginx-cont -p 80:80 -i  Nginx-img

但是出现以下错误

Failed to get D-Bus connection: Operation not permitted

解决方法

您需要centos7 systemd image才能在容器中运行systemctl

有了图片后,

更改

From centos:centos7 line in the dockerfile

From <new image name>

仅此而已,您会很高兴

OR

您可以直接将nginx图片用于服务器

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。