5.6.10
Elastic 版本:5.6.10 官方教程
docker pull docker.elastic.co/elasticsearch/elasticsearch:5.6.10
# 开发模式下快速启动一个 elastic
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:5.6.10
# 创建数据卷
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -v elasticdata:/usr/share/elasticsearch/data --privileged -v full_path_to/custom_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:5.6.10
- 第一个
-v
挂载了一个卷:数据目录存储 - 第二个
-v
挂载了本地的一个文件:elastic 的配置文件
使用 docker-compose,docker-compose.yml
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.10
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
volumes:
- esdata:/usr/share/elasticsearch/data
- ./custom_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
ports:
- 9200:9200
- 9300:9300
volumes:
esdata:
driver: local
custom_elasticsearch.yml
discovery:
type: single-node # 单节点模式
network:
host: 0.0.0.0 # 开放远程访问
xpack:
security:
enabled: false # 关闭用户名密码保护
6.6.0
docker-compose.yml
elasticsearch6.6.0:
image: docker.elastic.co/elasticsearch/elasticsearch:6.6.0
container_name: elasticsearch_660
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
volumes:
- ./elasticsearch6.6.0/data:/usr/share/elasticsearch/data
- ./elasticsearch6.6.0/custom_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
ports:
- 9200:9200
- 9300:9300
custom_elasticsearch.yml
discovery:
type: single-node # 单节点模式
network:
host: 0.0.0.0 # 开放远程访问
# 外部访问 es 时使用的 IP 地址,如果不配置,会自动选择其中一张网卡的地址,有可能就选择错了网卡地址,导致你本机通过发布的地址也访问不了 es
# 查看该地址可以使用 http://127.0.0.1:9200/_nodes/http?pretty 查看
publish_host: 127.0.0.1
xpack:
security:
enabled: false # 关闭用户名密码保护
启动后访问:http://localhost:9200/ 能看到 Elasticsearch 的版本等信息返回
可以访问 http://127.0.0.1:9200/_nodes/http?pretty 查看节点状态信息
{
"_nodes": {
"total": 1,
"successful": 1,
"failed": 0
},
"cluster_name": "docker-cluster",
"nodes": {
"vpS-dFp8SJe73RKL_ylVnw": {
"name": "vpS-dFp",
"transport_address": "127.0.0.1:9300",
"host": "127.0.0.1",
"ip": "127.0.0.1",
"version": "6.6.0",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "a9861f4",
"roles": [
"master",
"data",
"ingest"
],
"attributes": {
"ml.machine_memory": "2082197504",
"xpack.installed": "true",
"ml.max_open_jobs": "20",
"ml.enabled": "true"
},
"http": {
"bound_address": [
"0.0.0.0:9200"
],
"publish_address": "127.0.0.1:9200",
"max_content_length_in_bytes": 104857600
}
}
}
}
7.17.6
docker-compose.yml
version: "3.9"
services:
es:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.6
container_name: es
environment:
- TZ=Asia/Shanghai
- node.name=es01
- cluster.name=es-docker-cluster
- bootstrap.memory_lock=true
volumes:
- ./elasticsearch/data:/usr/share/elasticsearch/data
- ./elasticsearch/custom_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
ports:
- 9200:9200
- 9300:9300
custom_elasticsearch.yml
discovery:
type: single-node # 单节点模式
network:
host: 0.0.0.0 # 开放远程访问
# 外部访问 es 时使用的 IP 地址,如果不配置,会自动选择其中一张网卡的地址,有可能就选择错了网卡地址,导致你本机通过发布的地址也访问不了 es
# 查看该地址可以使用 http://127.0.0.1:9200/_nodes/http?pretty 查看
publish_host: 127.0.0.1
xpack:
security:
enabled: false # 关闭用户名密码保护