1、挂载路径
cd /data/logging/es
mkdir config data plugins
chmod -R 777 config data plugins #给这些文件赋予权限,因为一些是需要elasticsearc用户的
2、运行容器
docker run -it --name=es -v /data/logging/es/data:/usr/share/elasticsearch/data -v /data/logging/es/plugins:/usr/share/elasticsearch/plugins -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx1g" -p 9200:9200 -p 9300:9300 elastic:7.17.22
3、将/usr/share/elasticsearch/config/elasticsearch.yml文件复制到宿主机,以方便后续修改配置
docker cp id:/usr/share/elasticsearch/config/elasticsearch.yml /data/logging/es/config/
4、新增挂载运行
docker run -it --name=es -v /data/logging/es/data:/usr/share/elasticsearch/data -v /data/logging/es/plugins:/usr/share/elasticsearch/plugins -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx1g" -p 9200:9200 -p 9300:9300 registry.cn-hangzhou.aliyuncs.com
http://ip:9200,访问成功