• Uncategorized

About linux : How-to-store-elasticsearch-data-locally-in-host-machine

Question Detail

I have came across this question which is very similar,

Docker bind elasticsearch volume in app folder

and here’s one the answer:

https://stackoverflow.com/a/69441244

They suggested in the docker-compose file in the volumes I need to give,

./esdata which means current directory. But the answer says we need to give permissions 1000:1000 and username is elasticsearch:elasticsearch.

How can I create that permission and username. In my linux system I have a personal user name called ubuntu and a root. I don’t have a user called elasticsearch. Please help me out.

services:
  elasticsearch:
    # Elasticsearch Instance
    container_name: gs-search
    image: docker.elastic.co/elasticsearch/elasticsearch:7.16.2
    volumes:
      # Persist ES data in seperate "esdata" volume
      - ./esdata:/usr/share/elasticsearch/data
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms6g -Xmx6g"
      - discovery.type=single-node
      - xpack.security.enabled=true
      - ELASTIC_PASSWORD=$ELASTIC_PASSWORD
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      # Expose Elasticsearch ports
      - "9301:9300"
      - "9201:9200"

Question Answer

You can easily create user/group in Ubuntu following this guide. You can then login with the user elasticsearch and up your docker-compose. However, you don’t need additional user account every time a new container runs under a new identity; if you grant group permissions to the data directory that you will bind to the Elasticsearch, example:

mkdir data
chmod 770 data
docker run -p 9200:9200 -p 9300:9300 -v ~/data:/usr/share/elasticsearch/data -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.16.2

This will run just fine on a local machine.

About linux : How-to-store-elasticsearch-data-locally-in-host-machine

Question Detail

I have came across this question which is very similar,

Docker bind elasticsearch volume in app folder

and here’s one the answer:

https://stackoverflow.com/a/69441244

They suggested in the docker-compose file in the volumes I need to give,

./esdata which means current directory. But the answer says we need to give permissions 1000:1000 and username is elasticsearch:elasticsearch.

How can I create that permission and username. In my linux system I have a personal user name called ubuntu and a root. I don’t have a user called elasticsearch. Please help me out.

services:
  elasticsearch:
    # Elasticsearch Instance
    container_name: gs-search
    image: docker.elastic.co/elasticsearch/elasticsearch:7.16.2
    volumes:
      # Persist ES data in seperate "esdata" volume
      - ./esdata:/usr/share/elasticsearch/data
    environment:
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms6g -Xmx6g"
      - discovery.type=single-node
      - xpack.security.enabled=true
      - ELASTIC_PASSWORD=$ELASTIC_PASSWORD
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      # Expose Elasticsearch ports
      - "9301:9300"
      - "9201:9200"

Question Answer

You can easily create user/group in Ubuntu following this guide. You can then login with the user elasticsearch and up your docker-compose. However, you don’t need additional user account every time a new container runs under a new identity; if you grant group permissions to the data directory that you will bind to the Elasticsearch, example:

mkdir data
chmod 770 data
docker run -p 9200:9200 -p 9300:9300 -v ~/data:/usr/share/elasticsearch/data -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.16.2

This will run just fine on a local machine.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.