Cannot start elasticsearch from Docker

Hello, I want to install elasticsearch using Docker, this is in docker-compose.yml:

version: '2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:5.6.16
    container_name: elasticsearch
    restart: unless-stopped
    environment:
      - network.host=127.0.0.1
      - http.port=9200
      - cluster.name=elasticsearch
      - node.name="db-master"
      - node.master=true
      - node.data=true
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    mem_limit: 2g
    volumes:
      - esdata:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - esnet

volumes:
  esdata:
    driver: local

networks:
  esnet:

After docker-compose up I will get:

elasticsearch is up-to-date
Attaching to elasticsearch
elasticsearch exited with code 137

There is 4GB RAM on the server.

Your heap size should be 50% of available RAM. Here you have set both to 2GB which will not work.

1 Like

So it means that elasticsearch can use only 50% of available RAM? What to do with another 50%? Because it is wasted then.

Elasticsearch uses both heap and off-heap RAM, e.g. for the operating system file cache, so all available memory is usually used.

1 Like

Ah okey, so it started and one more question, elastic started on port 9300, why? I set it to be on 9200.

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