by Devin Yang

建立於: 8年前 ( 更新: 8年前 )

Docker內建相當多的日誌機制,幫我們取得在container內執行的服務資訊。
這些機制(mechanisms)我們通常稱為logging drivers.

如果要變更預設的日誌記錄驅動程序(logging drivers),可在daemon.json文件設置login-driver程序的名稱。這個檔案通常放在linux系統的/etc/docker目錄下,或在Windows則是C:\ProgramData\docker\config\
Docker預設的logging driver是json-file,把他變更為syslog。


在MacOS的系統,可以由Docker喜好設定進行設更:
daemon.json
重啟後會發覺日誌記錄變到了syslog了。


關於更多的Docker Deamon組態設定,可以參考官方連結:
https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file

用指令來查詢預設的Logging Driver.
docker info |grep Logging

下方為支援的Loggin drivers列表:
Driver Description
none No logs will be available for the container and  docker logs  will not return any output.
json-file The logs are formatted as JSON. The default logging driver for Docker.
syslog Writes logging messages to the  syslog  facility. The  syslog daemon must be running on the host machine.
journald Writes log messages to  journald . The  journald  daemon must be running on the host machine.
gelf Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.
fluentd Writes log messages to  fluentd  (forward input). The  fluentd daemon must be running on the host machine.
awslogs Writes log messages to Amazon CloudWatch Logs.
splunk Writes log messages to  splunk  using the HTTP Event Collector.
etwlogs Writes log messages as Event Tracing for Windows (ETW) events. Only available on Windows platforms.
gcplogs Writes log messages to Google Cloud Platform (GCP) Logging.
logentries Writes log messages to Rapid7 Logentries.

我可以在用docker run指令創建container時,
或是docker-compose啟動時,指定要使用的logging driver.
舉例,我的Synolog Nas上的dokcer,莫明跑了一個奇怪的logging driver叫db。(下圖)


我想讓我的docker-compose啟動時,執行json-file。
就可以補上
loggin:
  driver: json-file

 

Tags: docker

Devin Yang

文章內容無法一一說明,如果您有什麼不了解處,歡迎提問哦:)

No Comment

Post your comment

需要登入才可留言!

類似的文章


wordpress, d-laravel, docker, docker-compose

如何用D-Laravel安裝Wordpress

約8分鐘的教學影片,介紹在D-Laravel上安裝Wordpress. D-Laravel是一個docker-compose的Laravel框架開發環境,但不代表他不能拿來裝別的東西。 這個影片,介紹使用D-Laravel安裝非Laravel的PHP專案, 您可以學到D-Laravel上的相關指令用法: ./create --host用法, docker-compose up -d及 ./console mysql用法, D-Laravel v1.0.0版後的資料庫連線設定方式。

docker

如何在Raspberry上用Docker啟動HAProxy

Raspberry很便宜有相當多的運用,例如有人拿來當Wifi的router, 遊戲機,監視器及許許多多物聯網相關運用,我則是用他來當一台HAProxy。 長話短說,因為有一台老舊的Windows伺服器,他執行舊版本的PHP及Apache,並且無法設定HTTPS憑證,所以就想說 透過HAProxy來幫忙啦。讓這台老舊伺服器也可以有https的網址, 所以來分享我的docker-compose.yml設。

docker

D-Laravel上.env及docker-compsoe小教室

本文介紹,當我們使用D-Laravel的.env載入多個yml檔時,為何docker-compose ps官方指令無法列出所有使用中的服務。 但在D-Laravel上的./console ps確能正常顯示,那官方的docker-compose指令因如何使用才能有相同的效果呢?