无法获得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图片用于服务器

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...