- 创建挂载目录
mkdir -p /home/software/elasticsearch5.6.12_mall/data
mkdir -p /home/software/elasticsearch5.6.12_mall/config
mkdir -p /home/software/elasticsearch5.6.12_mall/logs
mkdir -p /home/software/elasticsearch5.6.12_mall/plugins
2.增加elasticsearch.yml和log4j2.properties配置文件
# cat elasticsearch.yml
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
# cat log4j2.properties
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
3.创建容器
docker run -p 19200:9200 -p 19300:9300 --name elasticsearch5.6.12_mall \
-d --restart=always \
-e TZ="Asia/Shanghai" \
-e "discovery.type=single-node" \
-e "cluster.name=elasticsearch" \
-e ES_JAVA_OPTS="-Xms2048m -Xmx4096m" \
--privileged=true \
-v /home/software/elasticsearch5.6.12_mall/plugins:/usr/share/elasticsearch/plugins \
-v /home/software/elasticsearch5.6.12_mall/data:/usr/share/elasticsearch/data \
-v /home/software/elasticsearch5.6.12_mall/config/elasticsearch.yml:/usr/share/elasticsearch/\
config/elasticsearch.yml \
-v /home/software/elasticsearch5.6.12_mall/config/log4j2.properties:/usr/share/elasticsearch/\
config/log4j2.properties \
-v /home/software/elasticsearch5.6.12_mall/logs:/usr/share/elasticsearch/logs \
elasticsearch:5.6.12
3.安装分词插件
#docker exec -it 9e2ae883e39d /bin/bash
root@9e2ae883e39d:elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.12/elasticsearch-analysis-ik-5.6.12.zip
# docker restart 9e2ae883e39d