Docker安装ElasticSearch
一、查找镜像
`docker search elastic`
| NAME| DESCRIPTION | STARS|OFFICIAL|AUTOMATED|
| --- | --- | --- | --- | --- | --- |
| elasticsearch | Elasticsearch is a powerful open source sear… |6215|[OK]|
| kibanar | Kibana gives shape to any kind of data — str… | 2664 | [OK] |
拉取镜像
`docker pull elastic:8.11.0`
查看镜像列表
`docker images`
安装镜像
~~~
docker run -d \
--name es \
-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
-e "discovery.type=single-node" \
-v es-data:/usr/server/elk/elasticsearch/data \
-v es-plugins:/usr/server/elk/elasticsearch/plugins \
--privileged \
--network es-net \
-p 9200:9200 \
-p 9300:9300 \
elasticsearch:8.11.0
~~~
命令解释:
* `-e "cluster.name=es-docker-cluster"`:设置集群名称
* `-e "http.host=0.0.0.0"`:监听的地址,可以外网访问
* `-e "ES_JAVA_OPTS=-Xms512m -Xmx512m"`:内存大小
* `-e "discovery.type=single-node"`:非集群模式
* `-v es-data:/usr/server/elk/elasticsearch/data`:挂载逻辑卷,绑定es的数据目录
* `-v es-logs:/usr/server/elk/elasticsearch/logs`:挂载逻辑卷,绑定es的日志目录
* `-v es-plugins:/usr/server/elk/elasticsearch/plugins`:挂载逻辑卷,绑定es的插件目录
* `--privileged`:授予逻辑卷访问权
* `--network es-net`:加入一个名为es-net的网络中
* `-p 9200:9200`:端口映射配置