2017-04-19 113 views
1

我一直在試圖獲取日誌格式:搬運工,撰寫JSON記錄駕駛員的標籤/ env的

{"log":"Using CATALINA_BASE: /opt/apache-tomcat- 
7.0.76\r\n","stream":"stdout","time":"2017-04- 
19T04:28:33.608418994Z","attrs": 
{"production_status":"testing","os":"ubuntu"}} 

我使用泊塢窗 - compose.yml:

version: '2.1' 
services: 
    web: 
    image: hello-world/web:latest 
    container_name: api 
    ports: 
     - "80:8080" 
logging: 
    driver: "json-file" 
    options: 
    max-size: 10m 
    max-file: "3" 
    labels: testing 
    env: ubuntu 

但我不明白日誌中的「attrs」鍵。我究竟做錯了什麼?

+0

你知道嗎? –

回答

2

根據我的測試,有兩件東西讓標籤/環境變量顯示在日誌中。

  1. 指定哪些標籤/環境變量在日誌中顯示
  2. 將容器

因此,要得到你想要的,你需要設置docker-這些標籤/環境變量compose.yml到:

version: '2.1' 
services: 
    web: 
    image: hello-world/web:latest 
    container_name: api 
    ports: 
     - "80:8080" 
    logging: 
     driver: "json-file" 
     options: 
     max-size: 10m 
     max-file: "3" 
     labels: "production_status" 
     env: "os" 
    labels: 
     production_status: "testing" 
    environment: 
     - os=ubuntu