1、docker search elasticsearch
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
elasticsearch Elasticsearch is a powerful open source sear… 4896 [OK]
nshou/elasticsearch-kibana Elasticsearch-7.10.1 Kibana-7.10.1 125 [OK]
itzg/elasticsearch Provides an easily configurable Elasticsearc… 71 [OK]
elastichq/elasticsearch-hq Official Docker image for ElasticHQ: Elastic… 70 [OK]
mobz/elasticsearch-head elasticsearch-head front-end and standalone … 70
elastic/elasticsearch The Elasticsearch Docker image maintained by… 46
bitnami/elasticsearch Bitnami Docker Image for Elasticsearch 38 [OK]
taskrabbit/elasticsearch-dump Import and export tools for elasticsearch 27 [OK]
2、docker pull elasticsearch
Using default tag: latest
latest: Pulling from library/elasticsearch
05d1a5232b46: Pull complete
5cee356eda6b: Pull complete
89d3385f0fd3: Pull complete
65dd87f6620b: Pull complete
78a183a01190: Pull complete
1a4499c85f97: Pull complete
2c9d39b4bfc1: Pull complete
1b1cec2222c9: Pull complete
59ff4ce9df68: Pull complete
1976bc3ee432: Pull complete
5af49e8af381: Pull complete
42c8b75ff7af: Pull complete
7e6902915254: Pull complete
99853874fa54: Pull complete
596fbad6fcff: Pull complete
Digest: sha256:a8081d995ef3443dc6d077093172a5931e02cdb8ffddbf05c67e01d348a9770e
Status: Downloaded newer image for elasticsearch:latest
docker.io/library/elasticsearch:latest
3、docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest c8562eaf9d81 7 weeks ago 546MB
redis latest 621ceef7494a 2 months ago 104MB
elasticsearch latest 5acf0e8da90b 2 years ago 486MB
4、创建目录
mkdir -p /home/elasticsearch/config
mkdir -p /home/elasticsearch/data
echo "http.host: 0.0.0.0">>/home/elasticsearch/config/elasticsearch.yml
注:http:host: 0.0.0.0冒号后有一空格
5、赋权
chmod -R 777 /home/elasticsearch
6、命令启动
docker run --name fbelasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx128m" -v /home/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /home/elasticsearch/data:/usr/share/elasticsearch/data -v /home/elasticsearch/plugins:/usr/share/elasticsearch/plugins -d elasticsearch
7、docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a4ffc386cc68 elasticsearch "/docker-entrypoint.…" About a minute ago Up About a minute 0.0.0.0:9200->9200/tcp, 9300/tcp fbelasticsearch
8、远程访问验证
浏览器:192.168.1.253:9200
9、启动容器自启
docker update elasticsearch --restart=always
第二种启动方式:
docker-compose启动
version: '2' services: elasticsearch: container_name: elasticsearch image: elasticsearch:7.7.0 ports: - "9200:9200" volumes: - /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml - /mydata/elasticsearch/data:/usr/share/elasticsearch/data - /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins environment: - "ES_JAVA_OPTS=-Xms64m -Xmx128m" - "discovery.type=single-node" - "COMPOSE_PROJECT_NAME=elasticsearch-server" restart: always