Apache Access/Error 日志未填充在 Docker 具有主管 D 的容器中

Apache Access/Error Logs Not Populated in Docker Container with Supervisor D

我 运行 Apache 2.4.7 在 Ubuntu 容器中,Apache access/error 日志没有被填充。这是 Dockefile:

FROM ubuntu:14.04
MAINTAINER me@mysite.com

RUN apt-get update
RUN apt-get install -y apache2 supervisor php5 php5-mysql php5-cli

RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/supervisor

RUN a2enmod rewrite
RUN a2enmod ssl
RUN a2enmod headers

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY pickle /etc/logrotate.d/pickle
COPY pickle_socket /etc/logrotate.d/pickle_socket
COPY pickleudp /etc/logrotate.d/pickleudp

ADD 000-default.conf /etc/apache2/sites-enabled/
ADD default-ssl.conf /etc/apache2/sites-enabled/
ADD apache2.conf /etc/apache2/
ADD www-server/ /www-server/

EXPOSE 80 443 

CMD ["/usr/bin/supervisord"]

SupervidorD 配置文件。其他服务在这里启动,但不相关:

[supervisord]
nodaemon=true

[program:apache2]
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"

最后是 Apache 设置和写入日志文件的 000-default.conf:

<VirtualHost *:80>

    DocumentRoot /www-server/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

<Directory /www-server/>
    # prevent potential clickjacking
    Header always append X-Frame-Options SAMEORIGIN
    # allow .htaccess overrides to work
    AllowOverride All
    DirectoryIndex login.html index.html index.php
</Directory>

我已确认在 /etc/apache2/envvars - export APACHE_LOG_DIR=/var/log/apache2$SUFFIX

中设置了适当的指令

经过大量研究、阅读错误报告等。与开始时相比,我并没有更接近于解决问题。我是否做错了什么来填充日志文件?或者当 运行 Apache 在 Docker 容器中时,我必须注意什么?

经过一番挖掘,我找到了 access/error 日志 在 Docker 容器 下的 /var/log/supervisor/ 中,according to Supervisor's docs,是所有此类子进程日志的典型位置:

The stdout of child processes spawned by supervisor, by default, is captured for redisplay to users of supervisorctl and other clients. If no specific logfile-related configuration is performed in a [program:x], [fcgi-program:x], or [eventlistener:x] section in the configuration file, the following is true:

  • supervisord will capture the child process’ stdout and stderr output into temporary files. Each stream is captured to a separate file. This is known as AUTO log mode.
  • AUTO log files are named automatically and placed in the directory configured as childlogdir of the supervisord section of the config file. -The size of each AUTO log file is bounded by the {streamname}_logfile_maxbytes value of the program section (where {streamname} is “stdout” or “stderr”). When it reaches that number, it is rotated (like the activity log), based on the {streamname}_logfile_backups.