0

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"
user_12
  • 1,778
  • 7
  • 31
  • 72

1 Answers1

0

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.

gohm'c
  • 13,492
  • 1
  • 9
  • 16