Hi,
I am trying to bring up an ES cluster on docker by following the instructions given here.
I am using named volume to provide persistence for the data. However docker-compose up fails due to permission issue. I see that it is mounted as root instead of 'elasticsearch' user.
docker-compose.yml:
version: '2.2'
services:
es-docker-master1:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.0
container_name: es-docker-master1
environment:
- cluster.name=es-prod-docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms4g -Xmx4g"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- es-master1:/data/es-data
- "./es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
ports:
- 9201:9200
networks:
- esnet
es-docker-data1:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.0
container_name: es-docker-data1
environment:
- cluster.name=es-prod-docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms14g -Xmx14g"
- "discovery.zen.ping.unicast.hosts=es-docker-master1"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
- es-data1:/data/es-data
- "./es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
ports:
- 9301:9300
networks:
- esnet
volumes:
es-master1:
driver: local
es-data1:
driver: local
networks:
esnet:
Here's the folder permission on one of the container:
[root@adfe78904e50 elasticsearch]# ls -lrt /data/
total 0
drwxr-xr-x. 2 root root 6 Jun 21 10:03 es-data
What is the right way to mount it so that the folder has correct permissions?
The folder has ownership for UID:GID - 1000:1000 (which incidentally also happens to be the UID/GID of a local user on the host machine)
[airvana@es-data-host es-docker]$ cd /data/
[airvana@es-data-host data]$ ll
total 24
drwxrwxr-x. 4 airvana airvana 4096 Jun 21 18:15 es-data
drwxrwxr-x. 3 airvana airvana 4096 Jun 21 18:18 es-logs
[airvana@es-data-host data]$ id
uid=1000(airvana) gid=1000(airvana) groups=1000(airvana),10(wheel),372(docker) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c
Thanks.