Elasticsearch memlock limits in docker service/swarm env

Hi,

how can I properly set the memlock limits when I run elastic as a docker service, without building custom docker image?
p.s. it works with compose or as standalone container because of ulimits settings..

Thank you

Martin

version: "3.3"

    configs:
      elasticsearch.yml:
        file: ./docker-configs/elasticsearch/usr/share/elasticsearch/config/elasticsearch.yml

    volumes:
      elastics-data:

    services:
      elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch:5.6.8
        configs:
          - source: elasticsearch.yml
            target: /usr/share/elasticsearch/config/elasticsearch.yml
    # ulimits unsupported with docker service
    #    ulimits:
    #      memlock:
    #          soft: -1
    #          hard: -1
        environment:
          - bootstrap.memory_lock=true
          - "ES_JAVA_OPTS=-Xms128m -Xmx128m"
        volumes:
          - elastics-data:/usr/share/elasticsearch/data

elasticsearch.yml:

cluster.name: "elasticsearch"
network.host: 0.0.0.0

xpack.security.enabled: false
xpack.monitoring.enabled: true
xpack.ml.enabled: false
xpack.watcher.enabled: false

error:

XXX_swarm1-1    | [2018-02-27T18:05:43,713][WARN ][o.e.b.JNANatives         ] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
XXX_swarm1-1    | [2018-02-27T18:06:07,968][WARN ][o.e.b.JNANatives         ] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
XXX_swarm1-1    | [2018-02-27T18:06:07,971][WARN ][o.e.b.JNANatives         ] This can result in part of the JVM being swapped out.
XXX_swarm1-1    | [2018-02-27T18:05:43,715][WARN ][o.e.b.JNANatives         ] This can result in part of the JVM being swapped out.
XXX_swarm1-1    | [2018-02-27T18:06:07,971][WARN ][o.e.b.JNANatives         ] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
XXX_swarm1-1    | [2018-02-27T18:05:43,715][WARN ][o.e.b.JNANatives         ] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
XXX_swarm1-1    | [2018-02-27T18:05:43,723][WARN ][o.e.b.JNANatives         ] These can be adjusted by modifying /etc/security/limits.conf, for example: 
XXX_swarm1-1    | [2018-02-27T18:06:07,971][WARN ][o.e.b.JNANatives         ] These can be adjusted by modifying /etc/security/limits.conf, for example: 
XXX_swarm1-1    |  # allow user 'elasticsearch' mlockall
XXX_swarm1-1    |  # allow user 'elasticsearch' mlockall
XXX_swarm1-1    |  elasticsearch soft memlock unlimited
XXX_swarm1-1    |  elasticsearch soft memlock unlimited
XXX_swarm1-1    |  elasticsearch hard memlock unlimited
XXX_swarm1-1    |  elasticsearch hard memlock unlimited

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.