拉取镜像文件
sudo docker pull elasticsearch:7.12.0
创建容器挂载目录
sudo mkdir -p /home/elasticsearch/config
sudo mkdir -p /home/elasticsearch/data
sudo mkdir -p /home/elasticsearch/plugins
elasticsearch.yml
http.host: 0.0.0.0
创建容器
sudo docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms84m -Xmx512m" \
-v /home/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/elasticsearch/data:/usr/share/elasticsearch/data \
-v /home/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.12.0
-
-p 端口映射
-
-e discovery.type=single-node 单点模式启动
-
-e ES_JAVA_OPTS="-Xms84m -Xmx512m":设置启动占用的内存范围
-
-v 目录挂载
-
-d 后台运行
docker ps 查看是否启动
docker logs elasticsearch 启动日志查询
docker restart elasticsearch 重启
docker exec -it elasticsearch bash 进入