Я получаю следующую ошибку при попытке подключения к кластеру mongodb - ReplicaSet (не в докеризированном виде) развернут на трех разных серверах с помощью приложения с загрузочной пружиной dockerized.
2020-04-06 19:40:06.263 INFO 1 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[196.12.7.156:27017, 196.12.7.157:27017, 196.12.7.158:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2020-04-06 19:40:06.263 INFO 1 --- [ main] org.mongodb.driver.cluster : Adding discovered server 196.12.7.156:27017 to client view of cluster
2020-04-06 19:40:06.301 INFO 1 --- [ main] org.mongodb.driver.cluster : Adding discovered server 196.12.7.157:27017 to client view of cluster
2020-04-06 19:40:06.304 INFO 1 --- [ main] org.mongodb.driver.cluster : Adding discovered server 196.12.7.158:27017 to client view of cluster
2020-04-06 19:40:06.424 INFO 1 --- [.16.8.179:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:3, serverValue:33289}] to 196.12.7.158:27017
2020-04-06 19:40:06.427 INFO 1 --- [.16.8.179:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=196.12.7.158:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 11]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=1686431, setName='rs0', canonicalAddress=seabatch3:27017, hosts=[seabatch3:27017, seabatch1:27017, seabatch2:27017], passives=[], arbiters=[], primary='seabatch1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=6, lastWriteDate=null, lastUpdateTimeNanos=2764696590071705}
2020-04-06 19:40:06.433 INFO 1 --- [.16.8.177:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:75063}] to 196.12.7.156:27017
2020-04-06 19:40:06.434 INFO 1 --- [.16.8.178:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:2, serverValue:24932}] to 196.12.7.157:27017
2020-04-06 19:40:06.435 INFO 1 --- [.16.8.179:27017] org.mongodb.driver.cluster : Discovered cluster type of REPLICA_SET
2020-04-06 19:40:06.438 INFO 1 --- [.16.8.177:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=196.12.7.156:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 11]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=4744734, setName='rs0', canonicalAddress=seabatch1:27017, hosts=[seabatch3:27017, seabatch1:27017, seabatch2:27017], passives=[], arbiters=[], primary='seabatch1:27017', tagSet=TagSet{[]}, electionId=7fffffff0000000000000061, setVersion=6, lastWriteDate=null, lastUpdateTimeNanos=2764696601428299}
2020-04-06 19:40:06.438 INFO 1 --- [.16.8.178:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=196.12.7.157:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 11]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=3873250, setName='rs0', canonicalAddress=seabatch2:27017, hosts=[seabatch3:27017, seabatch1:27017, seabatch2:27017], passives=[], arbiters=[], primary='seabatch1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=6, lastWriteDate=null, lastUpdateTimeNanos=2764696602199597}
2020-04-06 19:40:06.441 INFO 1 --- [.16.8.179:27017] org.mongodb.driver.cluster : Adding discovered server seabatch3:27017 to client view of cluster
2020-04-06 19:40:06.447 INFO 1 --- [.16.8.179:27017] org.mongodb.driver.cluster : Adding discovered server seabatch1:27017 to client view of cluster
2020-04-06 19:40:06.455 INFO 1 --- [.16.8.179:27017] org.mongodb.driver.cluster : Adding discovered server seabatch2:27017 to client view of cluster
2020-04-06 19:40:06.461 INFO 1 --- ['}-seabatch3:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server seabatch3:27017
com.mongodb.MongoSocketException: seabatch3: Name does not resolve
at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:211) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:75) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.11.2.jar!/:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
Caused by: java.net.UnknownHostException: seabatch3: Name does not resolve
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_212]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929) ~[na:1.8.0_212]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324) ~[na:1.8.0_212]
at java.net.InetAddress.getAllByName0(InetAddress.java:1277) ~[na:1.8.0_212]
at java.net.InetAddress.getAllByName(InetAddress.java:1193) ~[na:1.8.0_212]
at java.net.InetAddress.getAllByName(InetAddress.java:1127) ~[na:1.8.0_212]
at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:203) ~[mongodb-driver-core-3.11.2.jar!/:na]
... 5 common frames omitted
2020-04-06 19:40:06.466 INFO 1 --- ['}-seabatch1:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server seabatch1:27017
com.mongodb.MongoSocketException: seabatch1: Name does not resolve
at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:211) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:75) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.11.2.jar!/:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
Caused by: java.net.UnknownHostException: seabatch1: Name does not resolve
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_212]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929) ~[na:1.8.0_212]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324) ~[na:1.8.0_212]
at java.net.InetAddress.getAllByName0(InetAddress.java:1277) ~[na:1.8.0_212]
at java.net.InetAddress.getAllByName(InetAddress.java:1193) ~[na:1.8.0_212]
at java.net.InetAddress.getAllByName(InetAddress.java:1127) ~[na:1.8.0_212]
at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:203) ~[mongodb-driver-core-3.11.2.jar!/:na]
... 5 common frames omitted
2020-04-06 19:40:06.466 INFO 1 --- [.16.8.179:27017] org.mongodb.driver.cluster : Canonical address seabatch3:27017 does not match server address. Removing 196.12.7.158:27017 from client view of cluster
2020-04-06 19:40:06.474 INFO 1 --- [.16.8.178:27017] org.mongodb.driver.cluster : Canonical address seabatch2:27017 does not match server address. Removing 196.12.7.157:27017 from client view of cluster
2020-04-06 19:40:06.474 INFO 1 --- ['}-seabatch2:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server seabatch2:27017
com.mongodb.MongoSocketException: seabatch2: Name does not resolve
at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:211) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:75) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128) ~[mongodb-driver-core-3.11.2.jar!/:na]
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117) ~[mongodb-driver-core-3.11.2.jar!/:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
Caused by: java.net.UnknownHostException: seabatch2: Name does not resolve
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_212]
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929) ~[na:1.8.0_212]
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324) ~[na:1.8.0_212]
at java.net.InetAddress.getAllByName0(InetAddress.java:1277) ~[na:1.8.0_212]
at java.net.InetAddress.getAllByName(InetAddress.java:1193) ~[na:1.8.0_212]
at java.net.InetAddress.getAllByName(InetAddress.java:1127) ~[na:1.8.0_212]
at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:203) ~[mongodb-driver-core-3.11.2.jar!/:na]
... 5 common frames omitted
Первоначально он подключается к кластер mongodb и получение имен хостов, а затем приложение не запускается.
Я предполагаю, что поскольку приложение развернуто в контейнере docker, docker предполагает, что mongodb также развернут в другом контейнере и пытается его найти через имена контейнеров.
Любое предложение о том, как я могу решить эту проблему, очень помогло бы.
Спасибо!