How do I set the path.repo in Docker compose 3?
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.
version: "3"
services:
elasticsearch:
image: elasticsearch:6.8.2
environment:
- 'path.repo=/opt/elasticsearch/backup'