Docker撰写3个控制资源(内存,cpu)

时间:2017-02-13 13:57:53

标签: docker docker-compose

我试图使用"资源"来自docker的字段撰写版本3文档(https://docs.docker.com/compose/compose-file/),但是,我正面临错误,

  

错误:撰写文件' ./ docker-compose.yml'无效,因为:   services.fstore_java不支持的配置选项:' resources'

如何使用docker-compose设置内存限制?

  fstore_java:
    depends_on:
      - fstore_db
      - rabbit_broker
    build: ./fstore
    ports:
      - "8080:8080"
    expose:
      - "8080"
    links:
      - fstore_db
      - rabbit_broker
    restart: always
    resources:
      limits:
        cpus: '0.001'
        memory: 50M

1 个答案:

答案 0 :(得分:1)

必须处于“部署”级别

  fstore_java:
depends_on:
  - fstore_db
  - rabbit_broker
build: ./fstore
ports:
  - "8080:8080"
expose:
  - "8080"
links:
  - fstore_db
  - rabbit_broker
restart: always
deploy:
  resources:
  limits:
    cpus: '0.001'
    memory: 50M