问题描述
我正在尝试使用在其上运行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图片用于服务器