I have the following docker-compose file :
version: "3.3"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.1.1
volumes:
- esdata:/usr/share/elasticsearch/data
environment:
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.type=single-node
ports:
- "9300:9300"
- "9200:9200"
volumes:
esdata:
(I removed other services for clarity) I can see the volume in /var/lib/docker/volumes/project_name_esdata but I would like to be able to create the volume in the directory where the docker-compose.yml is but I didn't find a way to do so.
Inspired from How to set a path on host for a named volume in docker-compose.yml, I tried
version: "3.3"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.1.1
volumes:
- esdata:/usr/share/elasticsearch/data
environment:
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.type=single-node
ports:
- "9300:9300"
- "9200:9200"
volumes:
esdata:
driver: local
driver_opts:
type: 'none'
o: 'bind'
device: './'
But that raise the following exception :
Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes
Please, let me know if I should post the full stack trace or any other relevant informations.