docker部署es数据库

1.获取镜像

1
docker pull elasticsearch:7.14.0

2.创建相关文件夹

1
2
3
mkdir -p /mnt/d/java/share/elasticsearch/config
mkdir -p /mnt/d/java/share/elasticsearch/data
mkdir -p /mnt/d/java/share/elasticsearch/plugins

image-20230109160331272

3.配置文件

1
echo "http.host: 0.0.0.0" >> /mnt/d/java/share/elasticsearch/config/elasticsearch.yml

配置完成,可以执行命令查看

1
vim /mnt/d/java/share/elasticsearch/config/elasticsearch.yml

4.创建容器

1
2
3
4
5
6
7
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
> -e "discovery.type=single-node" \
> -e ES_JAVA_OPTS="-Xms84m -Xmx512m" \
> -v /mnt/d/java/share/elasticsearch/data:/usr/share/elasticsearch/data \
> -v /mnt/d/java/share/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
> -v /mnt/d/java/share/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
> -d elasticsearch:7.14.0

image-20230109160537007

5.测试正常移动页面

image-20230109160747537

参考文档