How to install logstash plugin with docker-compose?

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/

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 "