[Bug]: Container starts, but Spring Boot application gets connection refused #7299
Replies: 5 comments 7 replies
-
Hi, I moved this to a discussion instead. I don't think this is a bug, there are some projects running with |
Beta Was this translation helpful? Give feedback.
-
Sure, here is a code sample. This is the log output of the last PG driver version is 42.6.0. |
Beta Was this translation helpful? Give feedback.
-
No luck with Spring Boot 3.1.1. I can see It actually works the first time I run after restarting the docker engine, but then subsequent runs start to fail. I have upgraded it as well, but the problem persists. Here's what my docker version looks like now:
|
Beta Was this translation helpful? Give feedback.
-
Uh, it seems that adding |
Beta Was this translation helpful? Give feedback.
-
I am having the same problem with postgres and spring boot @DataJpaTest(properties = "spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect")
@Testcontainers
@AutoConfigureTestDatabase(replace = Replace.NONE)
class TestClass {
@Container
@ServiceConnection(type = JdbcConnectionDetails.class)
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16.3-alpine");
} |
Beta Was this translation helpful? Give feedback.
-
Module
PostgreSQL
Testcontainers version
1.18.3
Using the latest Testcontainers version?
Yes
Host OS
macOS Ventrua 13.0
Host Arch
ARM (Apple M2)
Docker version
Client: Version: 23.0.1-rd API version: 1.41 (downgraded from 1.42) Go version: go1.19.5 Git commit: 393499b Built: Fri Feb 10 16:54:39 2023 OS/Arch: darwin/arm64 Context: default Server: Engine: Version: 20.10.20 API version: 1.41 (minimum version 1.12) Go version: go1.18.7 Git commit: 03df974ae9e6c219862907efdd76ec2e77ec930b Built: Wed Oct 19 02:58:31 2022 OS/Arch: linux/arm64 Experimental: false containerd: Version: v1.6.8 GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6 runc: Version: 1.1.4 GitCommit: 5fd4c4d144137e991c4acebb2146ab1483a97925 docker-init: Version: 0.19.0 GitCommit:
What happened?
When trying to run an example Spring Boot (3.1) application, the testcontainer starts, but the application is not able to connect to it with the provided stacktrace.
pom.xml dependencies:
Sample test code:
I don't have any problem with other Docker applications whatsoever. This only happens with testcontainers. I am able to e.g. run this test with docker-compose and the same postgres image.
Using
@DynamicPropertySource
to inject properties instead of the newer@ServiceConnection
yields the same rsult.I have tried
docker system prune
several times but it didn't have any effect.Relevant log output
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions