Running Docker with a file

Hello Docker community,

I am extremely new to using Docker. I am running the ELK stack (elasticsearch, logstash, kibana) with the official images. Currently I have it up and running using the commands

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

For my own personal use it isn’t very hard to run these commands since I know a little about the syntax and what not. But I will be distributing Docker to other engineers and was hoping that I could somehow bundle these commands together (and whatever commands I end up using) in a file and run that. Sort of like a bash file but for Docker. I know that there are things called Dockerfiles but I am unsure if that is what I need. That seems more like creating a whole new image. Any tips?

Thanks!

I would use Docker Compose to start the images – https://docs.docker.com/compose/overview/

1 Like

So here is the compose file I came up with. But when I try to run docker-compose up I get this error:

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

Here is my configuration of the 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 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!

Hello,

The solution can be found in a similar subject here:

Regards,