(1)拉取镜像
这里命令是 `docker publl [镜像地址加速地址]/library/elasticsearch:版本号
[root@localhost ~]# docker pull 37y8py0j.mirror.aliyuncs.com/library/elasticsearch:7.1.0
Trying to pull repository 37y8py0j.mirror.aliyuncs.com/library/elasticsearch ...
7.1.0: Pulling from 37y8py0j.mirror.aliyuncs.com/library/elasticsearch
8ba884070f61: Pull complete
f09aa32454d9: Pull complete
b4a4ca7a82ce: Pull complete
2367280307d3: Pull complete
00c9d8373635: Pull complete
882233a52616: Pull complete
47cc7e043508: Pull complete
Digest: sha256:f449aeab752587709b440a9cb9b35ed93bfabdab75fb8ae9e0b330aa0e584a51
Status: Downloaded newer image for 37y8py0j.mirror.aliyuncs.com/library/elasticsearch:5.6.9
(2)下载成功之后,开始启动镜像
//先查看有哪些镜像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pshk7r7h.mirror.swr.myhuaweicloud.com/library/rabbitmq 3-management c4663bdca2cd 5 days ago 189 MB
37y8py0j.mirror.aliyuncs.com/library/elasticsearch 7.1.0 12ad640a1ec0 3 weeks ago 894 MB
docker.io/tomcat 7 bf7d94e5177f 3 months ago 359 MB
docker.io/mysql 5.7 ee7cbd482336 3 months ago 372 MB
//启动elasticsearch
//因为elasticsearch默认的启动 开辟的堆空间很大有4G,这样虚拟机根本吃不消,可以通过设置ES_JAVA_OPTS="-Xms256m -Xmx256m"限制最大,以及初始值
// -d 后台运行
// -p 映射端口 虚拟机端口:elasticsearch内部端口
[root@localhost ~]# docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9300:9300 -p 9200:9200 --name myelasticsearch 12ad640a1ec0
(3)访问安装elasticsearch虚拟机的 9200端口
访问之后看到返回你安装的elasticsearch相关信息的json字符串,那么就是安装成功了