<Without docker-compose.yml>
1. Install Docker
2. Elasticsearch 7.16.2
2-1. Install Elasticsearch
# docker pull docker.elastic.co/elasticsearch/elasticsearch:7.16.2
2-2. Execute Elasticsearch
# docker run -d -p 9200:9200 -p 9300:9300 --name es_x -e "discovery.type=single-node" -e "xpack.security.enabled=false" -e ES_JAVA_OPTS="-Xms200m -Xmx200m" docker.elastic.co/elasticsearch/elasticsearch:7.16.2
8fd1161fed14b8e048e0f929a37cfacbab56371dc4c2b134602469c321cc0421
2-3. Check Execution
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8fd1161fed14 docker.elastic.co/elasticsearch/elasticsearch:7.16.2 "/bin/tini -- /usr/l…" 45 seconds ago Up 43 seconds 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp es_x
2-4. Check your Elasticsearch settings
# docker exec -i -t es_x cat /usr/share/elasticsearch/config/elasticsearch.yml
cluster.name: "docker-cluster"
network.host: 0.0.0.0
2-5. Stop
# docker stop es_x
es_x
<With docker-compose.yml>
1. See up to and including Item 2-1.
2. docker-compose.yml
version: '3.6'
services:
elasticsearch:
image: 'docker.elastic.co/elasticsearch/elasticsearch:7.16.2'
container_name: es_a
ports:
- 9200:9200
environment:
- node.name="es_a"
- cluster.name="es-docker-cluster"
- bootstrap.memory_lock=true
- discovery.type=single-node
#- "ES_JAVA_OPTS=-Xms200m -Xmx200m"
volumes:
- ./esdata:/usr/share/elasticsearch/data
- ./eslog:/usr/share/elasticsearch/log
ulimits:
memlock:
soft: -1
hard: -1
networks:
- elastic
deploy:
resources:
limits:
memory: 1GB # Use at most 50 MB of RAM
elasticsearch2:
image: 'docker.elastic.co/elasticsearch/elasticsearch:7.16.2'
container_name: es_b
ports:
- 9201:9200
environment:
- node.name="es_b"
- cluster.name="es-docker-cluster2"
- bootstrap.memory_lock=true
- discovery.type=single-node
#- "ES_JAVA_OPTS=-Xms200m -Xmx200m"
volumes:
- ./esdata2:/usr/share/elasticsearch/data
- ./eslog2:/usr/share/elasticsearch/log
ulimits:
memlock:
soft: -1
hard: -1
networks:
- elastic2
deploy:
resources:
limits:
memory: 1GB # Use at most 50 MB of RAM
volumes:
esdata:
driver: local
driver_opts:
o: bind
type: none
#device: /data
esdata2:
driver: local
driver_opts:
o: bind
type: none
#device: /data2
eslog:
driver: local
eslog2:
driver: local
networks:
elastic:
driver: bridge
elastic2:
driver: bridge
# docker-compose -f docker-compose.yml up -d
# docker-compose -f docker-compose.yml stop
# docker-compose -f docker-compose.yml rm
3. Result
# docker-compose -f docker-compose.yml up -d
[+] Running 2/2
- Container es_a Started 2.1s
- Container es_b Started
# docker-compose -f docker-compose.yml stop
[+] Running 2/2
- Container es_a Stopped 1.2s
- Container es_b Stopped
3-1. 9200
{
"name" : "\"es_a\"",
"cluster_name" : "\"es-docker-cluster\"",
"cluster_uuid" : "KwFTIgGCT7e8ZDNJIau6Jw",
"version" : {
"number" : "7.16.2",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "2b937c44140b6559905130a8650c64dbd0879cfb",
"build_date" : "2021-12-18T19:42:46.604893745Z",
"build_snapshot" : false,
"lucene_version" : "8.10.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
3-2. 9201
{
"name" : "\"es_b\"",
"cluster_name" : "\"es-docker-cluster2\"",
"cluster_uuid" : "MZhKEnPuTdu5iNoatWOnQA",
"version" : {
"number" : "7.16.2",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "2b937c44140b6559905130a8650c64dbd0879cfb",
"build_date" : "2021-12-18T19:42:46.604893745Z",
"build_snapshot" : false,
"lucene_version" : "8.10.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
* If error raised 'Custom Analyzer [nori_korean] failed to find tokenizer under name [nori_tokenizer]'
Install Korean (nori) Analysis Plugin
# sudo bin/elasticsearch-plugin install analysis-nori
The plugin must be installed on every node in the cluster, and each node must be restarted after installation.
* Cannot bind to some ports due to permission denied
Run as admin:
net stop winnat
net start winnat
Ref.