1

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?

2
  • It is showing the expected path. container path you have configured it the wrong way. Commented Nov 9, 2021 at 13:41
  • So how should I configure the path? Commented Nov 9, 2021 at 13:45

1 Answer 1

7

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
Sign up to request clarification or add additional context in comments.

2 Comments

If the answer was useful, does it worth getting the reputation? You missed only container and host volume configuration.
Unfortunately... you need at least 15 reputation to cast a vote, but your feedback has been recorded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.