https://sukbeta.github.io/2018/11/21/ES-%E8%A7%A3%E5%86%B3-memory-lock-%E9%97%AE%E9%A2%98/

check
http://xxx.xxx.xxx.xxx:9200/_nodes?filter_path=**.mlockall

My way

  
services:  
  elasticsearch:  
    build:  
      context: elasticsearch/  
    volumes:  
      - ./elasticsearch/esdata:/usr/share/elasticsearch/data:rw  
      - ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro  
    ports:  
      - "9200:9200"  
      - "9300:9300"  
    environment:  
      - bootstrap.memory_lock=true  
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"  
    ulimits:  
      memlock:  
        soft: -1  
        hard: -1  
      nofile:  
        soft: 65536  
        hard: 65536  
    networks:  
      - elk