如何在Docker映像中预配置Elasticsearch管道?

时间:2018-10-10 03:38:42

标签: docker elasticsearch

我有一个Elasticsearch图像,它被用作多个容器的基础图像。我想知道是否有任何方法可以预先配置摄取管道,以使创建映像和构建容器的过程也为我创建管道?如果基础映像随附了我希望它具有的管道,那就太好了,否则我必须将docker exec放入使用该映像的每个容器中,并在每个容器中发送一个curl请求以创建管道。

现在我正在考虑要在docker-entrypoint.sh中的弹性搜索服务器上添加一个卷曲(在它启动之后),但是我不确定是否还有其他方法

1 个答案:

答案 0 :(得分:0)

我可以建议您使用docker-compose。我个人觉得很方便。使用一个文件,您可以配置整个堆栈。

以下是帮助您入门的示例:

 version: '2.2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
    container_name: elasticsearch
    environment:
      - cluster.name=docker-cluster
      - node.name=node-test1
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - node-test1data:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
  elasticsearch2:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.3.2
    container_name: elasticsearch2
    environment:
      - cluster.name=docker-cluster
      - node.name=node-test2
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - node-test2data:/usr/share/elasticsearch/data
  kibana:
    image: docker.elastic.co/kibana/kibana:6.3.2
    container_name: kibana
    ports:
      - 5601:5601
    environment:
      ELASTICSEARCH_URL: http://elasticsearch:9200
    depends_on:
       - elasticsearch
  logstash:
    image: docker.elastic.co/logstash/logstash:6.3.2
    container_name: logstash
    ports:
      - "5000:5000"
    environment:
      LS_JAVA_OPTS: "-Xmx256m -Xms256m"
    volumes:
      - ./logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml:ro
      - ./logstash/pipeline:/usr/share/logstash/pipeline:ro