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