MongoSocketException при подключении локально к docker образу
собираю локально проект. в docker-compose образ монго описан
mongo:
image: mongo
restart: always
ports:
- 27017:27017
запустил docker-compose, контейнер с монго работает
docker ps выводит
ad5412ad4685 | ... | 0.0.0.0:27017->27017/tcp | test-project-mongo-1
я так понимаю NAME это test-project-mongo-1 который нужно указать в пропертях проекта
spring:
application:
name: test-project
data:
mongodb:
host: api-gateway-mongo-1
port: 27017
при старте получаю
{"@timestamp":"2024-04-16T22:24:17.226+03:00","@version":1,"message":"No server chosen by com.mongodb.reactivestreams.client.internal.ClientSessionHelper$$Lambda$1699/0x000000080161a6b8@2fbb9d0b from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=api-gateway-mongo-1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: api-gateway-mongo-1}, caused by {java.net.UnknownHostException: api-gateway-mongo-1}}]}. Waiting for 30000 ms before timing out","logger_name":"org.mongodb.driver.cluster","thread_name":"restartedMain","level":"INFO","level_value":20000,"app-name":"unknown","app-version":"unknown"}