我在docker compose中为Elasticsearch安装卷时遇到问题。装载用于另一个磁盘,装载在:/mt/sda/
我使用以下docker-compose.yml:
version: "3.0"
services:
elasticsearch:
container_name: elastic-container-rescue
image: docker.elastic.co/elasticsearch/elasticsearch:7.15.0
volumes:
- es-data:/mt/sda/es-data
environment:
- xpack.security.enabled=true
- "discovery.type=single-node"
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- "network.host:0.0.0.0"
- ELASTIC_PASSWORD=$ES_PASS
ports:
- 9300:9200
networks:
- elastic
networks:
elastic:
driver: bridge
volumes:
es-data:
driver: local
当我用docker volume inspect
检查它时,它仍然显示不正确的装入点-它应该是:/mt/sda/es-data
{
"CreatedAt": "2021-11-09T13:51:05+01:00",
"Driver": "local",
"Labels": {
"com.docker.compose.project": "rescue-es",
"com.docker.compose.version": "1.25.5",
"com.docker.compose.volume": "es-data"
},
"Mountpoint": "/var/lib/docker/volumes/rescue-es_es-data/_data",
"Name": "rescue-es_es-data",
"Options": null,
"Scope": "local"
}
关于如何分配正确的装入点,有什么建议吗?
具有持久卷配置的Elasticsearch Docker容器
docker-compose.yml
version: "3.0"
services:
elasticsearch:
container_name: elastic-container-rescue
image: docker.elastic.co/elasticsearch/elasticsearch:7.15.0
volumes:
- es-data:/usr/share/elasticsearch/data
environment:
- xpack.security.enabled=true
- "discovery.type=single-node"
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
- "network.host:0.0.0.0"
- ELASTIC_PASSWORD=$ES_PASS
ports:
- 9300:9200
networks:
- elastic
networks:
elastic:
driver: bridge
volumes:
es-data:
driver: local
driver_opts:
o: bind
type: none
device: /mt/sda/es-data