'Why using docker compose gives other effect with ElasticSearch 8.1.2?

I am following the tutorial from: https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html to run Elasticsearch and Kibana using Docker (or better docker-compose). I just need one node for testing purposes.

When I use:

docker network create elastic
docker run --name es01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.1.2

Everything works well, I get the expected information with certificate fingerprint and Kibana enrollment token (screen below).

But when I try to do (I think) the same using docker-compose I end up not getting the information from the image below. My stack.yml:

version: "3.8"

services:
    elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch:8.1.2
        container_name: es01
        ports:
            - 9200:9200
            - 9300:9300

and then I run it with docker-compose -f stack.yml up. Which runs the conatiner. Elasticsearch is running, but it never shows the certificate fingerprint nor the enrollment token.

Why would those two cases behave differently?

(My final goal is just to have Elasticsearch - can be single node - and Kibana in one stack.yml configured and running together.)

enter image description here



Solution 1:[1]

Workaround: https://github.com/elastic/elasticsearch/issues/85047

Generating a new Password

docker exec -ti es01 /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic

Generating a new enrollment token

docker exec -ti es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Blob