# Elasticsearch memlock limits in docker service/swarm env

**URL:** <https://discuss.elastic.co/t/elasticsearch-memlock-limits-in-docker-service-swarm-env/121715>\
**Category:** Elasticsearch\
**Created:** [February 27, 2018, 6:10pm UTC](https://discuss.elastic.co/t/elasticsearch-memlock-limits-in-docker-service-swarm-env/121715 "2018-02-27T18:10:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcrm](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pcrm](https://discuss.elastic.co/u/pcrm)\
**Post date:** [February 27, 2018, 6:10pm UTC](https://discuss.elastic.co/t/elasticsearch-memlock-limits-in-docker-service-swarm-env/121715/1 "2018-02-27T18:10:37Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 27, 2018, 6:10pm UTC](https://discuss.elastic.co/t/elasticsearch-memlock-limits-in-docker-service-swarm-env/121715/2 "2018-03-27T18:10:51Z")

</div>

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