0
votes

docker-compose version 1.18.0, build 8dd22a9 on Ubuntu 16.04
Docker version 17.12.0-ce, build c97c6d6
docker-compose file version: '3'

Relevant portion of the docker-compose file

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 

When I do a docker-compose up -d, I get the following error:

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

Any ideas what's going on?

The docker-compose reference document seems to imply that since I've not running in swarm mode, I should be using the version 2 syntax for mem_limit even though my docker-compose file is version 3.

1

1 Answers

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

You got above error, because set mem_limit under the ulimits section. It should be under container level on the same level with image, environment etc:

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 

And another issue is here. According to the issue:

The v3 format is specifically designed to run with Swarm mode and the docker stack features. It wouldn't make sense for us to re-add options to that format when they have been replaced and would be ignored in Swarm mode.

It means that you can use cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit, mem_swappiness in version 2 only and use new resource options in version 3 in swarm mode only.

So, if you don't want to use swarm mode, you need to use version 2.

The final docker-compose.yml is:

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