Docker Community Forums

Share and learn in the Docker community.

How to specify max log json file size in docker compose?

docker

(Daiyue) #1

Hi, I am using docker 1.11.2. I am trying to specify the max file size for json-file in docker-compose.yml, like this,

log-opt:
max-size=50m

but when I tried to docker-compose up, it threw me an error,

ERROR: In file './docker-compose.yml', service 'log-opt' must be a mapping not a string.

How to fix it?

Update, I tried to put options in each service,
The whole yml file is

1 elasticsearch:
2   image: elasticsearch:latest
3   command: elasticsearch -Des.network.host=0.0.0.0
4   ports:
5     - "9200:9200"
6     - "9300:9300"
7   options:
8     max-size: 50m
9
10
11 logstash:
12   build: logstash/
13   command: logstash -f /etc/logstash/conf.d/logstash.conf
14   volumes:
15     - ./logstash/config:/etc/logstash/conf.d
16   ports:
17     - "5000:5000"
18   links:
19     - elasticsearch
20   options:
21     max-size: 50m
22
23
24 kibana:
25   build: kibana/
26   volumes:
27     - ./kibana/config/:/opt/kibana/config/
28   ports:
29     - "5601:5601"
30   links:
31     - elasticsearch
32   options:
33     max-size: 50m

I got the following errors,

ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for elasticsearch: 'options'
Unsupported config option for kibana: 'options'
Unsupported config option for logstash: 'options'

(Dikarel) #2

It seems to me you had a typo the first try. According to the docs, the setting should be called log_opt instead of log-opt.

I tried the following YML (docker 1.12.1, docker-compose 1.8.0) and it works:

elasticsearch:
  image: elasticsearch
  log_opt:
    max-size: 50m

(Daiyue) #3

Hi, yes, it works, figured it out last minute.