我一直在努力获取日志格式:
{"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"}}
我正在使用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: testing
env: ubuntu
但我没有在日志中获得“attrs”键。我做错了什么?
答案 0 :(得分:3)
根据我的测试,有两件可以让标签/环境变量显示在日志中。
所以,要获得你想要的东西,你需要将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