2017-06-02 46 views
1

在創建多克爾集裝箱,同時擁有的Apache2error.log和尾部它通過docker logs -f <my_container>我使用運行主管容器入口點與此配置:說明關於監事和尾巴在Apache的error.log中

[supervisord] 
nodaemon = true 
environment = PLACEHOLDER=true 
stdout_logfile=/dev/stdout 
stdout_logfile_maxbytes=0 
stderr_logfile=/dev/stderr 
stderr_logfile_maxbytes=0 

[program:apache] 
command=apache2ctl -DFOREGROUND 
autostart=true 
autorestart=true 
startretries=1 
startsecs=1 
stderr_logfile=/var/log/apache2/error.log 
stdout_logfile=/var/log/apache2/access.log 
user=root 
killasgroup=true 
stopasgroup=true 

[program:apache2-error] 
command= tail -f /var/log/apache2/error.log 
autostart = true 
autorestart = true 
stdout_logfile=/dev/stdout 
stdout_logfile_maxbytes=0 
stderr_logfile=/dev/stderr 
stderr_logfile_maxbytes=0 

[program:apache2-access] 
command= tail -f /var/log/apache2/access.log 
autostart = true 
autorestart = true 
stdout_logfile=/dev/stdout 
stdout_logfile_maxbytes=0 
stderr_logfile=/dev/stderr 
stderr_logfile_maxbytes=0 

這工作得很好,但我不明白爲什麼這不工作,如果我這個替換[program:apache]會議:

[program:apache] 
command=apache2ctl -DFOREGROUND 
autostart=true 
autorestart=true 
startretries=1 
startsecs=1 
user=root 
killasgroup=true 
stopasgroup=true 

即:沒有明確設置stderrstdout日誌文件docker logs -f <my_container>命令不起作用,但在容器tail -f /var/logs/apache2/access.logtail -f /var/logs/apache2/error.log內工作正常。

有人能解釋我爲什麼supervisordocker logs -f <my_container>由於在該配置的改變兩個不同的作品?

感謝

回答

1

監督員可以「看」的Apache2的標準輸出,並寫下你與stdout_file指定文件。問題是apache2不會將它的訪問日誌寫入stdout,而是將它寫入/ var/log/apache2中的文件。

所以,你看到在docker logs -f是該尾礦上司做您在stdout_file提供和系統管理員被轉發到自己的stdout如您在[supervosord]配置文件。

因此,當您從管理員中刪除apache2日誌文件配置時,沒有這樣的轉發;和apache2繼續寫入與以前相同的文件。

所以,你需要做的是告訴Apache的訪問日誌寫入/ dev /標準輸出,而不是在磁盤上的文件。您可以在Apache虛擬主機配置中執行此操作。

stderr同樣的事情。

+0

謝謝您的回答,但我不明白一件事:理論上一節'[程序:Apache2的訪問]'部分拖尾'access.log'文件,所以我認爲從輸出本節來臨應該由'docker logs -f'捕獲。爲什麼不是這樣? –