pblittle / docker-logstash

Docker image for Logstash 1.4
https://hub.docker.com/r/pblittle/docker-logstash
MIT License
237 stars 90 forks source link

QUESTION: How can I access the container's elasticsearch.yml? #107

Closed JacquesPerrault closed 8 years ago

JacquesPerrault commented 8 years ago

I am running Docker on Windows (yeah, "boo!", I know. moving on...). So Docker is running through VirtualBox, and I access Kibana on port 9292 on my host via the virtual network adapter bridging the host and container environment. I am running into the CORS issue resulting from ElasticSearch's security settings (host is 192.x.x.x, container is 172.x.x.x), and I need to set http.cors.allow-origin: "http://192.x.x.x:9292" and http.cors.enabled: true in elasticsearch.yml Those can't be set dynamically yet (as far as I know), and the -v parameter for Elastic doesn't help since my "local" .yml file only has those two parameters.

So either I need a complete copy of the elasticsearch.yml file (to use with -v), or I need to edit that file directly within the container. Any assistance you can provide would be greatly appreciated.

pblittle commented 8 years ago

@JacquesPerrault great question. Let's see if we can work through it.

To answer your first question, the default elasticsearch.yml path is /opt/logstash/elasticsearch.yml [0]. That is where Logstash looks for the Elasticsearch config file by default.

Your correct, the Elasticsearch config file isn't configurable. It wouldn't be hard. Before we look into that option let's make sure the current cors settings are the problem.

Right now http.cors.enabled is true [1] and http.cors.allow-origin is /.*/ [2]. Are you able to hit Elasticsearch directly on port 9200?

So, based on the above, do you still think cors is the issue? It very well could be. Hopefully this will help you get a little further. Please report your findings back. I'm interested in hearing what you're up against.

[0] https://github.com/pblittle/docker-logstash/blob/99a71394c48c98e1821db28fc456eae973cd1656/1.4/base/config.sh#L30 [1] https://github.com/pblittle/docker-logstash/blob/6eb445e028e079ab07ccb41b13330def6fbc61b6/1.4/base/elasticsearch.sh#L44 [2] https://github.com/pblittle/docker-logstash/blob/6eb445e028e079ab07ccb41b13330def6fbc61b6/1.4/base/elasticsearch.sh#L45

pblittle commented 8 years ago

@JacquesPerrault I forgot to mention how to get into the container in case you didn't know. If you are building from source, you can use make shell [0] to get in. Otherwise, docker exec -ti logstash /bin/bash should get you in.

[0] https://github.com/pblittle/docker-logstash/blob/master/1.4/Makefile#L70

JacquesPerrault commented 8 years ago

Just checking back - I'll work through the config links above and post when I have more.

JacquesPerrault commented 8 years ago

Neither of the following two commands resulted in Kibana talking to my Elasticsearch container: docker run --name logstash --link <your_es_container_name>:es -p 9292:9292 pblittle/docker-logstash

docker run --name logstash -e ES_HOST=<es_host_ip> -e ES_PORT=9200 -p 9200:9200 -p 9292:9292 pblittle/docker-logstash

What did work was allowing it to find the container on its own, via: docker run --name logstash -e ES_PORT=9200 -p 9200:9200 -p 9292:9292 pblittle/docker-logstash

Everything is copacetic, and I didn't have to touch the stock config files.