How does one use Apache in a Docker Container and write nothing to disk (all logs to STDIO / STDERR)?

前端 未结 6 905
不知归路
不知归路 2021-02-13 12:18

I\'m running Apache2 in a docker container and want to write nothing to the disk, writing logs to stdout and stderr. I\'ve seen a few different ways to do this (Supervisord and

6条回答
  •  一整个雨季
    2021-02-13 13:03

    According to the apache mailing list, you can just directly write to /dev/stdio (on Unix like systems) as that's just a regular ol' file handle. Easy! Pasting...

    The most efficient answer depends on your operating system. If you're on a UNIX like system which provides /dev/stdout and /dev/stderr (or perhaps /dev/fd/1 and /dev/fd/2) then use those file names. If that isn't an option use the piped output feature. For example, from my config:

    CustomLog "|/usr/sbin/rotatelogs -c -f -l -L
    /private/var/log/apache2/test-access.log
    /private/var/log/apache2/test-access.log.%Y-%m-%d 86400     "
    krader_custom ErrorLog "|/usr/sbin/rotatelogs -c -f -l -L
    /private/var/log/apache2/test-error.log
    /private/var/log/apache2/test-error.log.%Y-%m-%d 86400" 
    

    Obviously you'll want to substitute another program for /usr/sbin/rotatelogs in the example above that writes the data where you want it to go.

    https://mail-archives.apache.org/mod_mbox/httpd-users/201508.mbox/%3CCABx2=D-wdd8FYLkHMqiNOKmOaNYb-tAOB-AsSEf2p=ctd6sMdg@mail.gmail.com%3E

提交回复
热议问题