我运行最新版本的ES
sudo docker run --name elasticsearch --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.4.3
通过这样的命令运行可以看到下面的日志
--------------------------------------------------------------------------------------------------------------------------------------------------------------
-> Elasticsearch security features have been automatically configured!
-> Authentication is enabled and cluster connections are encrypted.
-> Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
8ttM*KCiYhFqKUAkfA07
-> HTTP CA certificate SHA-256 fingerprint:
42d3370add618542d597a5af94368757cb0cb7962315c87d373737545a8717c4
-> Configure Kibana to use this cluster:
* Run Kibana and click the configuration link in the terminal when Kibana starts.
* Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxNzIuMjQuMC4yOjkyMDAiXSwiZmdyIjoiNDJkMzM3MGFkZDYxODU0MmQ1OTdhNWFmOTQzNjg3NTdjYjBjYjc5NjIzMTVjODdkMzczNzM3NTQ1YTg3MTdjNCIsImtleSI6Ik5qZWZJb1FCR3V4ZzRZMHhVQ0pOOmhUendKYWZ2UkQ2d25OWG1xUWE2NGcifQ==
-> Configure other nodes to join this cluster:
* Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxNzIuMjQuMC4yOjkyMDAiXSwiZmdyIjoiNDJkMzM3MGFkZDYxODU0MmQ1OTdhNWFmOTQzNjg3NTdjYjBjYjc5NjIzMTVjODdkMzczNzM3NTQ1YTg3MTdjNCIsImtleSI6Ik56ZWZJb1FCR3V4ZzRZMHhVQ0pQOlBWRDhNSkNRUk9DYU42cWxHMnh6TGcifQ==
If you're running in Docker, copy the enrollment token and run:
`docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.4.3`
--------------------------------------------------------------------------------------------------------------------------------------------------------------
现在修改成docker-compose运行
文件内容如下
version: "2"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.4.3
container_name: elasticsearch
ports:
- "9200:9200"
- "9300:9300"
restart: always
networks:
- default
networks:
default:
external:
name: elastic
然后我这样去查看日志
sudo docker logs elasticsearch
没看到我要的日志,但是有其他的日志。
在
docker-compose.yml
目录下用docker-compose logs
去看,默认情况下会打印所有已有的日志,且不会持续追踪显示,可以使用docker-compose logs -f --tail=50
仅打印最新 50 条,并持续追踪关注。