apache不在高山图像泊坞窗中启动

时间:2018-11-23 10:47:24

标签: docker docker-compose dockerfile alpine

Apache不在高山docker映像中启动。这是我的Docker文件

 FROM alpine:latest
 RUN apk update
 RUN apk upgrade
 RUN apk add bash
 RUN apk add apache2
 RUN apk add openrc
 RUN rc-update add apache2
 EXPOSE 80 443
 WORKDIR /var/www/localhost/htdocs
 COPY  index.html  /var/www/localhost/htdocs 

登录到正在运行的docker后,我试图手动启动Apache

错误是

 * You are attempting to run an openrc service on a
 * system which openrc did not boot.
 * You may be inside a chroot or you may have used
 * another initialization system to boot this system.
 * In this situation, you will get unpredictable results!
 * If you really want to do this, issue the following command:
 * touch /run/openrc/softlevel
 * ERROR: networking failed to start
 * ERROR: cannot start apache2 as networking would not start

2 个答案:

答案 0 :(得分:1)

尝试一下:

FROM alpine:latest
RUN \
    apk add --no-cache \
    apache2-proxy \
    apache2-ssl \
    apache2-utils \
    curl \
    git \
    logrotate \
    openssl

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2

WORKDIR /var/www/localhost/htdocs
COPY  index.html  /var/www/localhost/htdocs 

EXPOSE 80

CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]

答案 1 :(得分:1)

我遇到了同样的问题,您可以不使用openrc来启动apache。

RUN mkdir -p /run/apache2添加到您的Dockerfile中,apache将httpd.pid文件存储在此目录中。最后使用:exec /usr/sbin/httpd -D FOREGROUND

开始apache。