请用docker-compose写出下面这段代码docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9201:9201 -p 9301:9301 \ -v /home/soft/ES/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml \ -v /home/soft/ES/data2:/usr/share/elasticsearch/data \ --name elasticsearch02 elasticsea
时间: 2023-07-06 12:43:12 浏览: 138
基于Docker安装Elasticsearch
好的,请看下面的docker-compose.yml文件:
```
version: '3'
services:
elasticsearch02:
image: elasticsearch
environment:
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
ports:
- "9201:9201"
- "9301:9301"
volumes:
- /home/soft/ES/config/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- /home/soft/ES/data2:/usr/share/elasticsearch/data
container_name: elasticsearch02
restart: always
```
你可以使用`docker-compose up -d`命令来启动容器。
阅读全文