Skip to content

Commit

Permalink
Add script to run ES in docker container (elastic#590)
Browse files Browse the repository at this point in the history
* Adding start_elasticsearch.sh script to run elastic search on the host
in a docker container at http://localhost:9200

* update readme in instructions on how to use script
  • Loading branch information
fxdgear authored and honzakral committed May 15, 2017
1 parent d336c57 commit 211ee23
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.eggs/*
.*.swp
*~
*.py[co]
Expand Down
20 changes: 20 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ Install the ``elasticsearch`` package with `pip
pip install elasticsearch


Run Elasticsearch in a Container
--------------------------------

To run elasticsearch in a container, optionally set the `ES_VERSION` environment evariable to either 5.4, 5.3 or 2.4. `ES_VERSION` is defaulted to `latest`.
Then run ./start_elasticsearch.sh::

export ES_VERSION=5.4
./start_elasticsearch.sh


This will run a version fo Elastic Search in a Docker container suitable for running the tests. To check that elasticearch is running
first wait for a `healthy` status in `docker ps`::

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
955e57564e53 7d2ad83f8446 "/docker-entrypoin..." 6 minutes ago Up 6 minutes (healthy) 0.0.0.0:9200->9200/tcp, 9300/tcp trusting_brattain

Then you can navigate to `locahost:9200` in your browser.


Example use
-----------

Expand Down
18 changes: 18 additions & 0 deletions start_elasticsearch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Start elasticsearch in a docker container

ES_VERSION=${ES_VERSION:-"latest"}
ES_TEST_SERVER=${ES_TEST_SERVER:-"http://localhost:9200"}

exec docker run -d \
-e script.inline=true \
-e path.repo=/tmp \
-e "repositories.url.allowed_urls=http://*" \
-e node.attr.testattr=test \
-e ES_HOST=$ES_TEST_SERVER \
-v `pwd`/../elasticsearch:/code/elasticsearch \
-v /tmp:/tmp \
-p "9200:9200" \
fxdgear/elasticsearch:$ES_VERSION

0 comments on commit 211ee23

Please sign in to comment.