Docker多容器日志logging上限

我试图限制docker日志文件的最大尺寸。 每个容器的日志文件应该最大为100M。 所以每个容器如edgeworker等只能被允许有一个100MB的日志文件。

我试图插入:

 log_opt: max-size: 100m 

在我的docker-compose.yml文件末尾,但是我收到一个错误。 我应该把它放在哪里? 另外,当我把它放在每个容器定义中,我得到一个错误。 我读了泊坞窗文档,但没有说在哪里放置选项。

这是我docker-compose.yml文件:

 version: '2.0' services: ubuntu: image: ubuntu volumes: - box:/box cache: image: redis:3.0 rabbitmq: image: rabbitmq:3-management volumes: - ${DATA}/rabbitmq:/var/lib/rabbitmq ports: - "15672:15672" - "5672:5672" placements-store: image: redis:3.0 command: redis-server ${REDIS_OPTIONS} ports: - "6379:6379" api: image: ruby:2.3 command: bundle exec puma -C config/puma.rb env_file: - ./.env working_dir: /app volumes: - .:/app/ - box:/box expose: - 3000 depends_on: - cache - placements-store worker: image: ruby:2.3 command: bundle exec sidekiq -C ./config/schedule.yml -q default -q high_priority,5 -c 10 env_file: - ./.env working_dir: /app environment: INSTANCE_TYPE: worker volumes: - .:/app/ - box:/box depends_on: - cache - placements-store sidekiq-monitor: image: ruby:2.3 command: bundle exec thin start -R sidekiq.ru -p 9494 env_file: - ./.env working_dir: /app volumes: - .:/app/ - box:/box depends_on: - cache expose: - 9494 sneakers: image: ruby:2.3 command: bundle exec rails sneakers:run env_file: - ./.env working_dir: /app environment: INSTANCE_TYPE: worker volumes: - .:/app/ - box:/box depends_on: - cache - placements-store - rabbitmq edge: image: ruby:2.3 command: bundle exec thin start -R config.ru -p 3000 environment: REDIS_URL: redis://placements-store RACK_ENV: development BUNDLE_PATH: /box RABBITMQ_HOST: rabbitmq working_dir: /app volumes: - ./edge:/app/ - box:/box depends_on: - placements-store - rabbitmq expose: - 3000 proxy: image: openresty/openresty:latest-xenial ports: - "80:80" - "443:443" volumes: - ./config/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf volumes: box: # node_modules: # bower_components: # client_dist: 

这是我尝试,例如在rabbitmq容器下插入:

 version: '2.0' services: ubuntu: image: ubuntu volumes: - box:/box cache: image: redis:3.0 rabbitmq: image: rabbitmq:3-management #volumes: # - ${DATA}/rabbitmq:/var/lib/rabbitmq ports: - "15672:15672" - "5672:5672" log_opt: max-size: 50m placements-store: image: redis:3.0 command: redis-server ${REDIS_OPTIONS} ports: - "6379:6379" 

这是我得到的错误:

错误:撰写文件“./docker-compose.yml”是无效的,因为:services.rabbitmq的不支持的configuration选项:'log_opt'

试图改变log_opt:options:并得到了同样的错误:

错误:撰写文件“./docker-compose.yml”是无效的,因为:services.rabbitmq的不支持的configuration选项:'选项'

docker版本是:

 docker --version && docker-compose --version Docker version 1.11.2, build b9f10c9/1.11.2 docker-compose version 1.9.0, build 2585387 

更新:

尝试使用logging选项,如文档所述(2.0版):

 version: '2.0' services: ubuntu: image: ubuntu volumes: - box:/box cache: image: redis:3.0 rabbitmq: image: rabbitmq:3-management #volumes: # - ${DATA}/rabbitmq:/var/lib/rabbitmq ports: - "15672:15672" - "5672:5672" logging: driver: "json-file" options: max-size: 100m max-file: 1 placements-store: image: redis:3.0 command: redis-server ${REDIS_OPTIONS} ports: - "6379:6379" 

获取错误:

错误:对于rabbitmq无法为服务创build容器rabbitmq:json:无法将数字解编码为stringtypes的Go值ERROR:启动项目时遇到错误。