英文:
Testcontainers cant seem to communicate - connection refused
问题
所以,我有一个容器设置如下:
genericContainer
.withImagePullPolicy(PullPolicy.alwaysPull())
.withExposedPorts(SPRING_BOOT_PORT)
.withNetwork(NETWORK)
.withAccessToHost(true);
这个容器启动正常,我可以ping它。
我还有另一个容器:
S3MockContainer(DockerImageName.parse("adobe/s3mock:2.4.13"))
.withInitialBuckets(S3_BUCKET_NAME)
.withNetwork(NETWORK);
但我似乎无法从我的第一个测试容器内部连接或ping S3Mock容器。我已经尝试传递 s3MockContainer.getHost() + getFirstMappedPort()
,但它似乎无法连接。
英文:
so i have one container set up like
genericContainer
.withImagePullPolicy(PullPolicy.alwaysPull())
.withExposedPorts(SPRING_BOOT_PORT)
.withNetwork(NETWORK)
.withAccessToHost(true);
this starts up fine and i can ping it.
I have another container
S3MockContainer(DockerImageName.parse("adobe/s3mock:2.4.13"))
.withInitialBuckets(S3_BUCKET_NAME)
.withNetwork(NETWORK);
I cant seem to connect or ping the s3Mock container from within my first test container. I have tried passing in the s3MockContainer.gethost() + getFirstMappedPort()
but it just is not able to connect?
答案1
得分: 1
Both containers are in the same network. So, in that case, you can use the real ports.
First, update S3MockContainer by adding withNetworkAliases("s3")
, then you can use s3:9090
in your spring boot app in order to connect to.
Also, I don't think you need withAccessToHost(true)
.
英文:
Both containers are in the same network. So, in that case, you can use the real ports.
First, update S3MockContainer by adding withNetworkAliases("s3")
, then you can use s3:9090
in your spring boot app in order to connect to.
Also, I don't think you need withAccessToHost(true)
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论