使用docker运行弹性搜索的本地实例

时间:2017-05-23 00:45:58

标签: elasticsearch docker-compose

我按照此处的说明https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html 并且只需要一个弹性搜索实例。当我运行docker-compose up时,收到错误消息The compose file docker-compose.yml is invalid because Unsupported config option for services.volumes: 'esdata1'

我做错了什么?

我的docker-compose文件

version: '2.1'
services:
  elasticsearch1:
    image: docker.elastic.co/elasticsearch/elasticsearch:5.4.0
    container_name: elasticsearch1
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    mem_limit: 1g
    volumes:
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200

1 个答案:

答案 0 :(得分:1)

您似乎错过了此处给出的示例文件末尾的顶级volumes部分(https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-prod-cluster-composefile)。

Docker Compose v2参考还指定了此要求 - https://docs.docker.com/compose/compose-file/compose-file-v2/#volumes-volumedriver

以上链接摘录: For version 2 files, named volumes need to be specified with the top-level volumes key.