問題描述
docker 發送內部 cerbot 日誌文件到主機 journald (docker send internal cerbot log file to host journald)
我正在構建一個嵌入了 nginx 和 certbot 的 docker 容器。
我希望能夠在主機上使用 journald 記錄 nginx 和 cerbot 的輸出。
nginx 輸出已經進入控制台,主機 journald 對此輸出工作正常。
我的問題是我需要能夠將以下文件發送到 journald。我希望能夠在主機上跟踪這些文件,因此需要實時發送。
文件是:
access.log
error.log
letsencrypt.log
certbot (letsencrypt) 似乎沒有提供除了寫入日誌文件之外的任何選擇。
所以我想我正在尋找一些進程來跟踪上述日誌文件,然後將輸出發送到控制台。
鑑於 nginx 已經連接到控制台,我能想到的唯一選擇是讓一個主線程假脫機。線程,每個進程/文件一個,然後將上述文件的所有輸出發送到“主”線程,然後將這些輸出到控制台。
我希望有一個更簡單的前進的方向。
參考解法
方法 1:
Give following a try:
- Disable letsencrypt log rotation
- soft link those files to
/dev/stdout
in container
</ol>
ln ‑s /dev/stdout access.log
ln ‑s /dev/stdout error.log
ln ‑s /dev/stdout letsencrypt.log
(by Brett Sutton、John Siu)