i try to dockerize my apps and i am tryimng to start 3 containers with docker compose. My docker-compose:
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
depends_on:
- zookeeper
healthcheck:
test: nc -z localhost 9092 || exit -1
start_period: 15s
interval: 5s
timeout: 10s
retries: 10
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"
depends_on:
kafka:
condition: service_healthy
deploy:
restart_policy:
condition: on-failure
delay: 10s
max_attempts: 3
window: 30s
The problem is that i get this error each time i staty docvker compose up:
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 i remove my service hu7manresources from docker compose and starting only zookeper and kafka containers then app from intelijidee its starting properly. Do you guys have some ideea why this happening?
My application.properties:
spring.h2.console.enabled=true
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 = localhost: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}