i am trying to dockerize 3 things: kafka , zookeper and spring app. But i get this error when i do docker compose
compose-humanresources-1 | 2022-11-19 09:14:59.941 WARN 1 --- [| adminclient-1] org.apache.kafka.clients.NetworkClient : [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
But if start only the containers:zookeper and kafka and start app from intelijIdee then the app is working properly.
Do you guys know ,whats the problem?? My docker compose:
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
humanresources:
image: univer-anu4/humanresources:latest
ports:
- "8081:8081"
environment:
- KAFKA_SERVERS=kafka:9092
depends_on:
- kafka
application.properties:
spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true
server.port=8081
spring.datasource.url=jdbc:h2:mem:DB
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.kafka.template.default-topic=pad2
eureka.client.service-url.defaultZone = http://localhost:7080/eureka/
kafka.bootstrapAddress = kafka:9092
spring.kafka.producer.bootstrap-servers=${KAFKA_SERVERS:127.0.0.1:9092}
spring.kafka.consumer.bootstrap-servers=${KAFKA_SERVERS:127.0.0.1:9092}
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.flyway.locations=classpath:db/migration
spring.flyway.enabled=true
spring.application.name=hr
eureka.instance.prefer-ip-address=true
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.instance.lease-renewal-interval-in-seconds=30
spring.kafka.consumer.group-id=${random.uuid}