如何使用docker-compose安装Logstash插件?

时间:2019-05-08 13:08:47

标签: docker-compose logstash

当我尝试安装logstash插件时,我尝试使用docker-compose安装logstash,但在exited with code 0之后使用docker Installation successful

docker-compose文件中用于logstash的部分是:

  logstash:
    image: docker.elastic.co/logstash/logstash-oss:7.0.1
    ports: ['9600:9600']
    command: bin/logstash-plugin install logstash-filter-metricize
    volumes:
      - ./logstash/pipeline/:/usr/share/logstash/pipeline/

日志为:

logstash_1       |Validating logstash-filter-metricize
logstash_1       |Installing logstash-filter-metricize
logstash_1       |Installation successful
logstash_1 exited with code 0

如果我尝试不安装插件,则我的docker-compose工作正常。安装插件时,我不明白我在做什么错。

2 个答案:

答案 0 :(得分:2)

安装后需要链接logstash启动命令。

  command: bash -c "bin/logstash-plugin install logstash-filter-metricize && logstash -f /etc/logstash/conf.d/logstash.conf "

答案 1 :(得分:0)

我使用Dockerfile对其进行修复。

我的Dockerfile

FROM docker.elastic.co/logstash/logstash-oss:7.0.1

RUN rm -f /usr/share/logstash/pipeline/logstash.conf && \
  bin/logstash-plugin install logstash-filter-metricize

docker-compose的一部分:

  logstash:
    build: 
      context: ./logstash
    ports: ['9600:9600']
    volumes:
      - ./logstash/pipeline/:/usr/share/logstash/pipeline/