[TOC]
>注意:本书ES版本选择为6.5.1
<br>
## 下载镜像
```
root@ubuntu:/home/guanfuchang# docker pull elasticsearch:6.5.1
```
```
root@ubuntu:/home/guanfuchang# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
elasticsearch 6.5.1 32f93c89076d 5 days ago 773MB
...
```
## 开启镜像并映射端口9200和9300(ElasticSearch的默认端口为9200)
```
root@ubuntu:/home/guanfuchang# docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -d elasticsearch:6.5.1
680a68077527e76a00391ec9e5ac311c259eb81369e645b60c2f6982dfe951f3
```
```
root@ubuntu:/home/guanfuchang# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
680a68077527 elasticsearch:6.5.1 "/usr/local/bin/dock…" 22 seconds ago Up 20 seconds 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp infallible_kepler
```
>[info]9300是tcp通讯端口,集群间和TCPClient都走的它;
9200是http协议的RESTful接口,后续的API接口测试都是走的它。
## 测试服务是否正常
```
root@ubuntu:/home/guanfuchang# curl 127.0.0.1:9200
{
"name" : "owKbL2X",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "xcQp0nCUT9CZcvWMvSx8vg",
"version" : {
"number" : "6.5.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "8c58350",
"build_date" : "2018-11-16T02:22:42.182257Z",
"build_snapshot" : false,
"lucene_version" : "7.5.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
```