一、依赖镜像
docker.elastic.co/elasticsearch/elasticsearch:6.2.2
docker.elastic.co/kibana/kibana:6.2.2
二、镜像添加ik后构建新镜像es622-ik:1.0 .
Dockerfile
FROM docker.elastic.co/elasticsearch/elasticsearch:6.2.2
MAINTAINER sunbin "sunb@citydo.com.cn"
RUN wget -c --tries=0 -O /tmp/elasticsearch-analysis-ik.zip https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.2/elasticsearch-analysis-ik-6.2.2.zip && \
unzip /tmp/elasticsearch-analysis-ik.zip -d /usr/share/elasticsearch/plugins && \
rm -rf /tmp/elasticsearch-analysis-ik.zip
构建新镜像
docker build -t es622-ik:1.0 .
三、根据上一步骤生成的镜像,通过docker-compose 构建启动
docker-compose.yml
version: '2.2'
services:
elasticsearch:
image: es622-ik:1.0
container_name: esearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
restart: always
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
mem_limit: 1g
cap_add:
- IPC_LOCK
volumes:
- $PWD/esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
- 9300:9300
networks:
- esnet
elasticsearch2:
image: es622-ik:1.0
container_name: elasticsearch2
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
restart: always
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
mem_limit: 1g
cap_add:
- IPC_LOCK
volumes:
- $PWD/esdata2:/usr/share/elasticsearch/esdata1
networks:
- esnet
elasticsearch3:
image: es622-ik:1.0
container_name: elasticsearch3
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
restart: always
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
mem_limit: 1g
cap_add:
- IPC_LOCK
volumes:
- $PWD/esdata3:/usr/share/elasticsearch/data
networks:
- esnet
elasticsearch4:
image: es622-ik:1.0
container_name: elasticsearch4
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=esearch"
restart: always
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
mem_limit: 1g
cap_add:
- IPC_LOCK
volumes:
- $PWD/esdata4:/usr/share/elasticsearch/data
networks:
- esnet
kibana:
image: docker.elastic.co/kibana/kibana:6.2.2
container_name: kibana
restart: always
depends_on:
- elasticsearch
environment:
SERVER_NAME: kibana
ELASTICSEARCH_URL: http://esearch:9200
#volumes:
# - ./kibana.yml:/usr/share/kibana/config/kibana.yml
ports:
- 5601:5601
networks:
- esnet
volumes:
esdata1:
driver: local
esdata2:
driver: local
esdata3:
driver: local
esdata4:
driver: local
networks:
esnet:
docker-compose up -d 启动
ps: 如es启动报/usr/share/elasticsearch/data 没有权限,需要在宿主机 esdata1-4 需要加权限 chmod 777 esdataX