简体   繁体   中英

How to add discovery.type=single-node in my Dockerfile

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?

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
   // ....

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM