docker-compose up -d在尝试在docker-compose.yml文件中设置mem_limit时给出“OCI运行时创建失败:错误的rlimit值”

时间:2018-01-21 08:52:24

标签: docker docker-compose

docker-compose版本1.18.0,在Ubuntu 16.04上构建8dd22a9
Docker版本17.12.0-ce,build c97c6d6
docker-compose文件版本:'3'

docker-compose文件的相关部分

elasticsearch1:
    image: docker.elastic.co/elasticsearch/elasticsearch:5.6.0
    container_name: elasticsearch1
    restart: unless-stopped
    environment:
        - http.host=0.0.0.0
        - reindex.remote.whitelist=remote_es:*
        - xpack.security.enabled=false
        - cluster.name=docker-cluster
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
        memlock:
            soft: -1
            hard: -1
        mem_limit: 1000000000
    volumes:
        - esdata1:/usr/share/elasticsearch/data
    ports:
        - 9200:9200 

当我做一个docker-compose up -d时,我收到以下错误:

ERROR: for elasticsearch1  Cannot start service elasticsearch1: OCI runtime create failed: wrong rlimit value: RLIMIT_MEM_LIMIT: unknown

任何想法发生了什么?

docker-compose reference document似乎意味着因为我没有在swarm模式下运行,所以即使我的docker-compose文件是版本3,我也应该使用mem_limit的第2版语法。

1 个答案:

答案 0 :(得分:0)

ERROR: for elasticsearch1  Cannot start service elasticsearch1: OCI runtime create failed: wrong rlimit value: RLIMIT_MEM_LIMIT: unknown

您遇到了上述错误,因为在mem_limit部分下设置了ulimits。它应该在与imageenvironment等相同级别的容器级别下:

elasticsearch1:
    image: docker.elastic.co/elasticsearch/elasticsearch:5.6.0
    container_name: elasticsearch1
    restart: unless-stopped
    environment:
        - http.host=0.0.0.0
        - reindex.remote.whitelist=remote_es:*
        - xpack.security.enabled=false
        - cluster.name=docker-cluster
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
        memlock:
            soft: -1
            hard: -1
    mem_limit: 1000000000
    volumes:
        - esdata1:/usr/share/elasticsearch/data
    ports:
        - 9200:9200 

另一个问题在这里。根据{{​​3}}:

  

v3格式专门设计为使用Swarm模式运行   docker stack功能。我们重新添加选项是没有意义的   更换时的格式,将被忽略   Swarm模式。

这意味着您只能在版本2中使用cpu_sharescpu_quotacpusetmem_limitmemswap_limitmem_swappiness并使用仅在群集模式下的版本3中issue

因此,如果您不想使用swarm模式,则需要使用版本2.

最终docker-compose.yml是:

version: '2'
services:
    elasticsearch1:
        image: docker.elastic.co/elasticsearch/elasticsearch:5.6.0
        container_name: elasticsearch1
        restart: unless-stopped
        environment:
            - http.host=0.0.0.0
            - reindex.remote.whitelist=remote_es:*
            - xpack.security.enabled=false
            - cluster.name=docker-cluster
            - bootstrap.memory_lock=true
            - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        ulimits:
            memlock:
                soft: -1
                hard: -1
        mem_limit: 1000000000
        volumes:
            - esdata1:/usr/share/elasticsearch/data
        ports:
            - 9200:9200