docker 安装elasticsearch

获取镜像

在线下载

bash 复制代码
docker pull elasticsearch:9.0.3

离线获取

百度云:https://pan.baidu.com/s/16yYtNPc9ho01KkoDBd-9jw?pwd=1125 提取码: 1125

安装

导入镜像

bash 复制代码
docker load -i docker.elasticsearch-9.0.3.tar

添加标签

bash 复制代码
docker tag 7bb65e5bbdd5 elasticsearch:9.0.3

创建挂载目录

bash 复制代码
mkdir -p /opt/docker/elasticsearch/{data,logs,config,plugins}

创建配置文件并写入内容

bash 复制代码
vim /opt/docker/elasticsearch/config/elasticsearch.yml
XML 复制代码
network.host: 0.0.0.0
http.cors.allow-origin: "*"
http.cors.enabled: true
xpack.security.enabled: false

赋权

XML 复制代码
chmod -R 777 /opt/docker/elasticsearch

创建容器

bash 复制代码
docker run --name elasticsearch.9.0.3 --network host \
-e "discovery.type=single-node" \
-v /opt/docker/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /opt/docker/elasticsearch/data:/usr/share/elasticsearch/data \
-v /opt/docker/elasticsearch/logs:/usr/share/elasticsearch/logs \
-v /opt/docker/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-d elasticsearch:9.0.3

验证访问

bash 复制代码
curl -X GET "http://localhost:9200"