Running logstash with docker compose

Im trying to run this in a docker compose file:

docker run -d -p 9200:9200 -p 9300:9300 -it -h elasticsearch --name elasticsearch elasticsearch

docker run -d -p 5601:5601 -h kibana --name kibana --link elasticsearch:elasticsearch kibana

docker run -d -h logstash --name logstash --link elasticsearch:elasticsearch -it --rm -v "$PWD":/config-dir logstash -f /config-dir/logstash.conf

Here is my docker-compose.yaml:

version: "3"
services:
  elasticsearch:
    image: elasticsearch
    ports: 
    - "9200:9200"
    - "9300:9300"
  kibana:
    image: kibana
    ports:
    - "5601:5601"
    links:
    - elasticsearch
  logstash:
    image: logstash
    links:
    - elasticsearch
    volumes:
    - ~:/config-dir
    file: /config-dir/logstash.conf

I got the error:

ERROR: The Compose file '.\docker-compose.yml is invalid because:
Unsupported config option for services.logstash: ‘file’

I cant seem to find anything that would tell me how to start the logstash with the configuration file which I am trying to specify.

Thanks!

I figured it out. My final yaml is:

version: "3"
services:
  elasticsearch:
    image: elasticsearch
    ports: 
    - "9200:9200"
    - "9300:9300"
  kibana:
    image: kibana
    ports:
    - "5601:5601"
    links:
    - elasticsearch
    depends_on:
    - elasticsearch
  logstash:
    image: logstash
    links:
    - elasticsearch
    volumes:
    - ./:/config-dir
    command: logstash -f /config-dir/logstash.conf
    depends_on:
    - elasticsearch

The command line is what I needed to add.