Image is working Dockerfile not?

Hi,

I´m a very newbie, so I´m sorry for this maybe stupid question

I have an issue:

If I use:

elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.15.0

I can access to localhost:9200
I can see also a lot of logs:

If I use:

elasticsearch:
    build:
      context: ${ROOT_DIR}/elasticsearch
      dockerfile: Dockerfile

Here my Dockerfile, it´s in folder: elasticsearch/
image

# Verwende das offizielle Elasticsearch-Image als Basis
FROM docker.elastic.co/elasticsearch/elasticsearch:8.15.0

EXPOSE 9200
EXPOSE 9300

# Kopiere das Skript in das Image
COPY setup_template_wildfly.sh /usr/share/elasticsearch/scripts/setup_template_wildfly.sh

# Überprüfe die Datei
RUN ls -l /usr/share/elasticsearch/scripts/setup_template_wildfly.sh

# Wechsle zu root, falls erforderlich
USER root

# Setze die Berechtigungen für das Skript
RUN chmod +x /usr/share/elasticsearch/scripts/setup_template_wildfly.sh

# Wechsel zurück zum Standardbenutzer (Elasticsearch läuft normalerweise unter dem Benutzer elasticsearch)
#USER elasticsearch

# Behalte den Standard-Eintragspunkt des Elasticsearch-Images
#ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

# Füge das benutzerdefinierte Skript als zusätzlichen Befehl hinzu
CMD ["sh", "-c", "/usr/share/elasticsearch/scripts/setup_template_wildfly.sh && elasticsearch"]

I cannot access localhost:9200

I can see in this case only the logs from the script:
image

I´ve tried also remove the script etc.

Here the whole docker-compose file:

volumes:
  elasticsearch_data_test:

services:
  elasticsearch:
    #image: docker.elastic.co/elasticsearch/elasticsearch:8.15.0
    build:
      context: ${ROOT_DIR}/elasticsearch
      dockerfile: Dockerfile
    container_name: elasticsearch
    restart: unless-stopped
    environment:
      - discovery.type=single-node
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
      - "ELASTIC_PASSWORD=${ELASTICSEARCH_PASSWORD}"             # Setzt das Passwort für den `elastic`-Benutzer
      - "xpack.security.enabled=false"                           # Stellt sicher, dass die Sicherheit aktiviert ist-> später aktivieren
     # - "xpack.security.transport.ssl.enabled=true"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ${ROOT_DIR}/elasticsearch:/elasticsearch
      - ${ROOT_DIR}/elasticsearch:/usr/share/elasticsearch/scripts
      - elasticsearch_data_test:/usr/share/elasticsearch/data
    ports:
      - "9200:9200"
      - "9300:9300"
 
    networks:
      - app-network
  
  
networks:
  app-network:
    external: true

What´s missing?

how is it different from the other topic?