testcontainers / testcontainers/testcontainers-java
No connection to Ryuk when running tests in Docker Compose on Ubuntu with `ufw` enabled
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
I'm trying to run a Docker container that spins up a test container through docker-compose and Gradle. Everything works fine in CircleCI, but it does not work on my VPS (fresh Ubuntu + Docker). CircleCI and the VPS both use the same versions:
Docker 20.10.12
Docker Compose 1.29.2
Ubuntu 20.04
Gradle 7.3
// In build.gradle.kts
implementation(platform("org.testcontainers:testcontainers-bom:1.16.3"))
implementation("org.testcontainers:mysql:1.16.3")
In Docker-compose.yml:
console_gradle:
image: openjdk:17-jdk
working_dir: /app/backend/console
volumes:
- ./app/backend:/app/backend
- /var/run/docker.sock:/var/run/docker.sock
entrypoint: [ './gradlew' ]
Running docker-compose:
docker-compose run console_gradle installDist
Running in build.gradle.kts:
...
> Task :core:startTestDatabase
Timed out waiting for Ryuk container to start. Ryuk's logs:
2022/02/05 21:36:35 Pinging Docker...
2022/02/05 21:36:35 Docker daemon is available!
2022/02/05 21:36:35 Starting on port 8080...
2022/02/05 21:36:35 Started!
...
The error:
...
Can not connect to Ryuk at 172.17.0.1:49153
java.net.SocketTimeoutException: Connect timed out
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:633)
at org.testcontainers.utility.ResourceReaper.lambda$null$3(ResourceReaper.java:194)
at org.rnorth.ducttape.ratelimits.RateLimiter.doWhenReady(RateLimiter.java:27)
at org.testcontainers.utility.ResourceReaper.lambda$start$4(ResourceReaper.java:190)
at java.base/java.lang.Thread.run(Thread.java:833)
Can not connect to Ryuk at 172.17.0.1:49153
java.net.SocketTimeoutException: Connect timed out
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:546)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:633)
at org.testcontainers.utility.ResourceReaper.lambda$null$3(ResourceReaper.java:194)
at org.rnorth.ducttape.ratelimits.RateLimiter.doWhenReady(RateLimiter.java:27)
at org.testcontainers.utility.ResourceReaper.lambda$start$4(ResourceReaper.java:190)
at java.base/java.lang.Thread.run(Thread.java:833)
...
What I've tried on the VPS:
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 testcontainers/ryuk:0.3.1
Which does succeed:
nc -zv localhost 8080
Connection to localhost 8080 port [tcp/http-alt] succeeded!
Anyone else experiencing this issue? Or does someone know a solution?
Thanks in advance! :)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Docker Compose service definition, the Gradle startTestDatabase task, and the Ryuk logs showing port 8080 and 172.17.0.1:49153. Reproduce on Ubuntu with UFW enabled, compare the successful host nc check with the container-to-Ryuk connection, and consider the issue complete when the test container can connect to Ryuk under the reported setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, java, ubuntu
- Domain
- devops, networking, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100