by Devin Yang

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

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

需要登入才可留言!

類似的文章


d-laravel, docker, docker-compose, laravel

D-Laravel釋出v0.9.1版了

為了讓D-Laravel保持在一個可運作的版本及穩定的本。 開始使用Tag標註該版本通過測試那些測試.. 這個版本已通過ubuntu實及macos實機測試,可順利建立Container及執行哦..

docker,phpenv

用光了Docker IPv4 address pool問題解法

可能在舊版的docker環境,使用Docker compose啟動容器時,會碰過下方的錯誤:

 Error response from daemon: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network這其實這是default-address-pools用光的症狀,有些環境,docker-compose預設會使用Class B的私有網路。172段的私有IP是有範圍的,從172.16.0.0到172.31.255.255。也就是說,當我們起動一個docker-compose的Project,就會吃掉一個Class B的私有段,非常豪邁,

docker,laravel

如何使用多個YAML檔,執行多個docker的container服務

這個影片介紹如何用docker-compose命令,指定多個YAML結構語言設定檔,來建立容器的執行,並且介紹在D-Laravel的使用環境中,我們如何透過使用.env的方式,簡化docker-compose的啟動命令。