安装方式基本有两种,一种是pull的方式,一种是Dockerfile的方式,由于pull的方式pull下来后还需配置许多东西且不便于复用,个人比较喜欢使用Dockerfile的方式
所有docker支持的镜像基本都在https://hub.docker.com/
docker的官网上能找到合适版本的Dockerfile
新建ElasticSearch文件夹
mkdir ElasticSearch
cd进入文件夹并新建Dockerfile
cd ElasticSearch
vim Dockerfile
Dockerfile的内容为(在官网上也能找到你要的elasticsearch的版本的Dockerfile,我这里是elasticsearch6.8.0的版本)
# Elasticsearch 6.8.0
# This image re-bundles the Docker image from the upstream provider, Elastic.
FROM docker.elastic.co/elasticsearch/elasticsearch:6.8.0@sha256:2c77f71d560053fec89564043c7eb2dca5dd3132d85ba1f233fc5db966827446
# The upstream image was built by:
# https://github.com/elastic/dockerfiles/tree/v6.8.0/elasticsearch
# For a full list of supported images and tags visit https://www.docker.elastic.co
# For Elasticsearch documentation visit https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
# See https://github.com/docker-library/official-images/pull/4916 for more details.
然后按下Esc键 :wq保存
:wq
开始制作镜像
sudo docker build -t elasticsearch .
运行
sudo docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:6.8.0
说明:
配置跨域
进入容器当中修改相应的配置信息
sudo docker exec -it es /bin/bash
查看文件
ls
cd config
查看文件
ls
修改elasticsearch.yml配置文件,加入跨域配置
跨域配置为
http.cors.enabled: true
http.cors.allow-origin: "*"
重启容器
sudo docker restart CONTAINER ID
elasticsearch-head是一个查看elasticsearch相关信息的管理界面
直接用pull拉取镜像
sudo docker pull mobz/elasticsearch-head:5
运行
sudo docker run -d --name es_admin -p 9100:9100 mobz/elasticsearch-head:5
新建kibana文件夹
mkdir kibana
cd进去kibana目录,新建Dockerfile
vim Dockerfile
Dockerfile的内容为(在官网上也能找到你要的kibana的版本,记得与你的elasticsearch版本保持一致哦,我这里是kibana6.8.0的版本)
# Kibana 6.8.0
# This image re-bundles the Docker image from the upstream provider, Elastic.
FROM docker.elastic.co/kibana/kibana:6.8.0@sha256:6d487c045e9a8e5bc092325185407216881981843210b35ab1166fcaf6f9472b
# The upstream image was built by:
# https://github.com/elastic/dockerfiles/tree/v6.8.0/kibana
# For a full list of supported images and tags visit https://www.docker.elastic.co
# For documentation visit https://www.elastic.co/guide/en/kibana/current/docker.html
# See https://github.com/docker-library/official-images/pull/4917 for more details.
开始构建镜像
sudo docker build -t kibana .
运行
sudo docker run -it -d -e ELASTICSEARCH_URL=http://127.0.0.1:9200 --name kibana -p 5601:5601 kibana:6.8.0
说明
进入elasticsearch容器
sudo docker exec -it es /bin/bash
查看文件
ls
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.8.0/elasticsearch-analysis-ik-6.8.0.zip
进入plugins目录创建ik文件夹
cd plugins
mkdir ik
将压缩包一到ik目录下
mv ../elasticsearch-analysis-ik-6.8.0.zip ./ik/
解压
unzip elasticsearch-analysis-ik-6.8.0.zip
重启elasticsearch
sudo docker restart CONTAINER ID
CONTAINER ID为你的es的CONTAINER ID
安装完毕