gpt4 book ai didi

Docker 在应用文件夹中绑定(bind) Elasticsearch 卷

转载 作者:行者123 更新时间:2023-12-04 19:27:12 41 4
gpt4 key购买 nike

我有以下 docker-compose 文件:

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:

(为了清楚起见,我删除了其他服务)
我可以在/var/lib/docker/volumes/ 中看到卷项目名称 _esdata 但我希望能够在 docker-compose.yml 所在的目录中创建卷,但我没有找到这样做的方法。

灵感来自 How to set a path on host for a named volume in docker-compose.yml , 我试过
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: './'

但这会引发以下异常:
Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes 

请让我知道我是否应该发布完整的堆栈跟踪或任何其他相关信息。

最佳答案

如果您使用 ./,该卷将安装在同一个文件夹中(我之前通过这样做遇到过权限问题,所以您知道)

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:

关于Docker 在应用文件夹中绑定(bind) Elasticsearch 卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52373356/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com