Add elasticsearch docker image

Signed-off-by: Qi Zheng <qi.zheng@intel.com>
This commit is contained in:
qzheng527
2019-04-16 16:25:18 +00:00
committed by William Douglas
parent 256680f7c6
commit 3086b7d190
7 changed files with 135 additions and 0 deletions
+1
View File
@@ -15,6 +15,7 @@ env:
- DOCKERFILE_DIR=nginx
- DOCKERFILE_DIR=redis
- DOCKERFILE_DIR=httpd
- DOCKERFILE_DIR=elasticsearch
- DOCKERFILE_DIR=cgit
script:
+1
View File
@@ -8,6 +8,7 @@ https://hub.docker.com/u/clearlinux/
Containers
----------
- clr-sdk
- elasticsearch
- httpd
- machine-learning
- mixer-ci
+27
View File
@@ -0,0 +1,27 @@
FROM clearlinux:latest
MAINTAINER qi.zheng@intel.com
ARG swupd_args
RUN swupd update $swupd_args \
&& swupd bundle-add elasticsearch $swupd_args \
&& rm -rf /var/lib/swupd/*
RUN set -ex \
&& for path in \
/var/data/elasticsearch \
/var/log/elasticsearch \
/etc/elasticsearch \
; do \
mkdir -p "$path"; \
chown -R elasticsearch:elasticsearch "$path"; \
done
COPY config /etc/elasticsearch
COPY docker-entrypoint.sh /
VOLUME /var/data/elasticsearch
EXPOSE 9200 9300
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["-Epath.conf=/etc/elasticsearch/"]
+58
View File
@@ -0,0 +1,58 @@
Elasticsearch
==========
This provides a Clear Linux* Elasticsearch instance.
Build
-----
```
docker build -t clearlinux/elasticsearch .
```
Or just pull it from Dockerhub
---------------------------
```
docker pull clearlinux/elasticsearch
```
Start a elasticsearch instance
-----------------------
```
docker run -d -p 9200:9200 -e "discovery.type=single-node" -v esdata:/var/data/elasticsearch clearlinux/elasticsearch
```
Set the configuration file to the path /etc/elasticsearch/ by default CMD "-Epath.conf=/etc/elasticsearch/".
Check cluster health
---------------------
```
curl http://localhost:9200/_cluster/health?pretty
```
Create an index called customer
---------------------
```
curl -X PUT "localhost:9200/customer?pretty"
```
Add new document to that index
---------------------
```
curl -X PUT "localhost:9200/customer/doc/1?pretty" -H 'Content-Type: application/json' -d'{"name": "Tom John" }'
curl -X PUT "localhost:9200/customer/doc/2?pretty" -H 'Content-Type: application/json' -d'{"name": "Kelly Wong" }'
```
View documents in the index
---------------------
```
curl localhost:9200/customer/_search?pretty
```
Details of how-to
---------------------
Please refer to [page](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docker.html).
Extra Build ARGs
----------------
- ``swupd_args`` Specifies [SWUPD](https://clearlinux.org/documentation/swupdate_how_to_run_the_updater.html) flags
Default build args in Docker are on: https://docs.docker.com/engine/reference/builder/#arg
+9
View File
@@ -0,0 +1,9 @@
http.host: 0.0.0.0
# Uncomment the following lines for a production cluster deployment
#transport.host: 0.0.0.0
#discovery.zen.minimum_master_nodes: 1
path:
data: /var/data/elasticsearch
logs: /var/log/elasticsearch
+9
View File
@@ -0,0 +1,9 @@
status = error
appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
rootLogger.level = info
rootLogger.appenderRef.console.ref = console
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
set -e
export PATH=/usr/share/elasticsearch/bin/:$PATH
# Add elasticsearch as command if needed
if [ "${1:0:1}" = '-' ]; then
set -- elasticsearch "$@"
fi
# Drop root privileges if we are running elasticsearch
# allow the container to be started with `--user`
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
# Change the ownership of user-mutable directories to elasticsearch
for path in \
/var/data/elasticsearch \
/var/log/elasticsearch \
; do
chown -R elasticsearch:elasticsearch "$path"
done
# use tmp file to avoid multiple parameters issue on su -c
echo "elasticsearch -s /bin/bash -c \"$0 $@\"" | xargs su
fi
# As argument is not related to elasticsearch,
# then assume that user wants to run his own process,
# for example a `bash` shell to explore this image
exec "$@"