I had a node app running Docker with elastic search 7. I want to add this option
discovery.type=single-node
to elasticsearch services. How can I add that to Dockerfile?
CodePudding user response:
For that, you have to add an environment file elasticsearch.env with contents like this.
cluster.name=my-elasticsearch-cluster
network.host=0.0.0.0
bootstrap.memory_lock=true
discovery.type=single-node # Here you can add that
After that, mention the env file in your docker-compose.yml
// ....
elastic:
image: elasticsearch:7.16.2
ports:
- "9200:9200"
env_file:
- ./elasticsearch.env
volumes:
- ./data/elasticsearch:/usr/share/elasticsearch/data
// ....
CodePudding user response:
With plain Docker like this (from the docs):
docker run -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.16.2
You don‘t add it to the Dockerfile directly normally to keep the image usable for single and multi node clusters. Passing in the environment variable does the job.