Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the path.repo in Docker compose 3?

I have the following Docker-compose 3 file:

version: '3'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4
    container_name: elasticsearch
    ...
    ...
    volumes:
      - /path/to/elasticsearch:/usr/share/elasticsearch/data
      - /path/to/elasticsearch/backup:/opt/elasticsearch/backup
    ports:
      - 9200:9200
    networks:
      - elasticnetwork

So, I've set my path.repo to /path/to/elasticsearch/backup. However, running curl http://127.0.0.1:9200/_nodes/?pretty results in no path.repo:

"settings" : {
        ...
        "path" : {
          "logs" : "/usr/share/elasticsearch/logs",
          "home" : "/usr/share/elasticsearch"
        },
        ...
      },

I'm expecting to see "repo" : ["/opt/elasticsearch/backup"] in the path.

like image 213
user_78361084 Avatar asked Feb 26 '19 05:02

user_78361084


2 Answers

version: "3"
services:
  elasticsearch:
    image: elasticsearch:6.8.2
    environment:
      - 'path.repo=/opt/elasticsearch/backup'
like image 144
flaviovs Avatar answered Nov 19 '22 10:11

flaviovs


As mentioned in the documentation, You have to set your path.repo in your elasticsearch.yml file. This file is at /usr/share/elasticsearch/config/ directory in your image.

So, your compose file should look something like this:

    version: '3'
    services:
      elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4
        container_name: elasticsearch
        volumes:
          - elastic-data:/usr/share/elasticsearch/data
          - elastic-backup:/usr/share/elasticsearch/backup
          - ./elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
        ports:
          - 9200:9200
        environment:
          discovery.type: single-node
    volumes:
      elastic-data:
      elastic-backup:

and your elasticsearch.yml should have these:

    cluster.name: "docker-cluster"
    network.host: 0.0.0.0
    
    # minimum_master_nodes need to be explicitly set when bound on a public IP
    # # set to 1 to allow single node clusters
    # # Details: https://github.com/elastic/elasticsearch/pull/17288
    # discovery.zen.minimum_master_nodes: 1
    path.repo: ["/usr/share/elasticsearch/backup"]

After starting the container, I could see the repo in the http://127.0.0.1:9200/_nodes/?pretty response:

    "settings" : {
            "cluster" : {
              "name" : "docker-cluster"
            },
            "node" : {
              "name" : "3cUpSf-"
            },
            "path" : {
              "logs" : "/usr/share/elasticsearch/logs",
              "home" : "/usr/share/elasticsearch",
              "repo" : [
                "/usr/share/elasticsearch/backup"
              ]
            },

From comment:

There is an user called elasticsearch which is created in this image and Elasticsearch binary runs in context of this user not root user, so this user doesn't have write permission on /opt directory inside the container, but it does have enough permission on /usr/share/elastisearch directory. That's the reason in my above example I have used this directory instead of the /opt/ dir.

like image 12
Thilak Avatar answered Nov 19 '22 11:11

Thilak