Skip to content

Commit 211ee23

Browse files
fxdgearhonzakral
authored andcommitted
Add script to run ES in docker container (elastic#590)
* 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
1 parent d336c57 commit 211ee23

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.eggs/*
12
.*.swp
23
*~
34
*.py[co]

README

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ Install the ``elasticsearch`` package with `pip
6666
pip install elasticsearch
6767

6868

69+
Run Elasticsearch in a Container
70+
--------------------------------
71+
72+
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`.
73+
Then run ./start_elasticsearch.sh::
74+
75+
export ES_VERSION=5.4
76+
./start_elasticsearch.sh
77+
78+
79+
This will run a version fo Elastic Search in a Docker container suitable for running the tests. To check that elasticearch is running
80+
first wait for a `healthy` status in `docker ps`::
81+
82+
$ docker ps
83+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
84+
955e57564e53 7d2ad83f8446 "/docker-entrypoin..." 6 minutes ago Up 6 minutes (healthy) 0.0.0.0:9200->9200/tcp, 9300/tcp trusting_brattain
85+
86+
Then you can navigate to `locahost:9200` in your browser.
87+
88+
6989
Example use
7090
-----------
7191

start_elasticsearch.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Start elasticsearch in a docker container
4+
5+
ES_VERSION=${ES_VERSION:-"latest"}
6+
ES_TEST_SERVER=${ES_TEST_SERVER:-"http://localhost:9200"}
7+
8+
exec docker run -d \
9+
-e script.inline=true \
10+
-e path.repo=/tmp \
11+
-e "repositories.url.allowed_urls=http://*" \
12+
-e node.attr.testattr=test \
13+
-e ES_HOST=$ES_TEST_SERVER \
14+
-v `pwd`/../elasticsearch:/code/elasticsearch \
15+
-v /tmp:/tmp \
16+
-p "9200:9200" \
17+
fxdgear/elasticsearch:$ES_VERSION
18+

0 commit comments

Comments
 (0)