简体   繁体   中英

Docker-compose persistent volume issue with elasticsearch

I have a problem with mounting a volume for Elasticsearch in docker-compose. The mount is for another disk, mounted at: /mt/sda/ I am using the following 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

When I check it with docker volume inspect , it still shows incorrect mountpoint - it should be: /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"
    }

Any suggestions on how to assign the correct mountpoint?

Elasticsearch Docker Container with Persistent Volume Configuration

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM