12

I try to install logstash with a docker-compose but docker exited with code 0 just after Installation successful when I try to install a logstash plugin.

The part of docker-compose file for logstash is:

  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/

And the logs are:

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

If I try without install the plugin, my docker-compose works fine. I don't understand what I'm doing wrong when I install the plugin.

B3n
  • 536
  • 1
  • 3
  • 16
  • 1
    your logstash part is doing your command section. So its run bin/logstash-plugin install after that installation its ended (without error ). You can add this command to step as a dockerfile or you can add another command for like '$@' https://stackoverflow.com/questions/39082768/what-does-set-e-and-exec-do-for-docker-entrypoint-scripts – Fahri May 08 '19 at 13:39

2 Answers2

21

I use a Dockerfile to fix it.

My 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

My part of docker-compose:

  logstash:
    build: 
      context: ./logstash
    ports: ['9600:9600']
    volumes:
      - ./logstash/pipeline/:/usr/share/logstash/pipeline/
B3n
  • 536
  • 1
  • 3
  • 16
9

You need to chain logstash startup command after install.

  command: bash -c "bin/logstash-plugin install logstash-filter-metricize && logstash -f /etc/logstash/conf.d/logstash.conf "
Hank
  • 1,318
  • 10
  • 29