Open Ivashkin-aa opened 1 year ago
Нужно убрать network_mode: host
. И тогда не придётся разносить инстансы на разные порты.
Хардкодить ИПы тоже плохая практика, нет грантий что они всегда будут такими.
И параметры лучше передавать через переменные окружения.
Поправил
smart@thinkpad$ docker compose --verbose up
[+] Building 0.0s (0/0)
[+] Running 4/4
✔ Network smallbllockchain_default Created 0.0s
✔ Container smallbllockchain-third-node-1 Created 0.1s
✔ Container smallbllockchain-second-node-1 Created 0.1s
✔ Container smallbllockchain-first-node-1 Created 0.1s
Attaching to smallbllockchain-first-node-1, smallbllockchain-second-node-1, smallbllockchain-third-node-1
smallbllockchain-third-node-1 | Exception in thread "main" java.net.ConnectException: Connection refused
smallbllockchain-third-node-1 | at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
smallbllockchain-third-node-1 | at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
smallbllockchain-third-node-1 | at io.ktor.network.sockets.SocketImpl.connect$ktor_network(SocketImpl.kt:50)
smallbllockchain-third-node-1 | at io.ktor.network.sockets.SocketImpl$connect$1.invokeSuspend(SocketImpl.kt)
smallbllockchain-third-node-1 | at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
smallbllockchain-third-node-1 | at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
smallbllockchain-third-node-1 | at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
smallbllockchain-third-node-1 | at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
smallbllockchain-third-node-1 | at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
smallbllockchain-third-node-1 | at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
smallbllockchain-third-node-1 | at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
smallbllockchain-third-node-1 | at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
smallbllockchain-third-node-1 | at com.example.MainKt.main(Main.kt:12)
smallbllockchain-third-node-1 exited with code 1
Нет смысла разносить по портам, у тебя есть разные хосты с уникальными ИПами. И посмотри на каком адресе ты слушаешь подключения.
@Ivashkin-aa ping
Student, group: Ivashkin Artyom, 3530901/90203 URL: https://github.com/Ivashkin-aa/SmallBllockchain Any comments: Kotlin, TBD