testcontainers-java: Ryuk container name already in use
The error message from docker is:
Conflict. The container name "/testcontainers-ryuk-181a7bc5-71b4-41c5-89ee-b5f0b0f378ed" is already in use by container "7b89e6644ce929b67b9934dd1caf2b414f98e7143490b20d2cdcc36645c60830". You have to remove (or rename) that container to be able to reuse that name.
Based on looking through the code, you are creating a static SESSION_ID
in the DockerClientFactory
but you are creating a Ryuk container per docker client. There isn’t a check for an existing container with that id.
I’m not sure what the correct solution is. The 2 options I see are:
- have a per-client session id
- handle the container already existing by checking and returning the id
We are using version 1.12.5
This happens during CI builds using docker-in-docker on BuildKite. EC2 hosts running Amazon Linux. Does not happen locally on macOS or on linux laptops.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 26 (11 by maintainers)
Commits related to this issue
- Cache Ryuk's failure to prevent the double start see #2395 — committed to testcontainers/testcontainers-java by bsideup 4 years ago
- Cache Ryuk's failure to prevent the double start (#2935) see #2395 — committed to testcontainers/testcontainers-java by bsideup 4 years ago
Also affected by this. Same setup.
Okay, after looking at the code, I noticed that we were not caching Ryuk’s failure: #2935
So, the actual problem was that
ResourceReaper
was failing to connect to started Ryuk container, but another attempt at getting a client would not know that and attempt to start it again.This logs confirms that: https://pastebin.com/pZHXKzRF
My tests worked fine on
1.12.4
, but start to fail1.13.0
with this error. Also running docker-in-docker.Please reopen. I am having this issue on a very uncomplicated “hello world” type of project, rendering the TestContainers library unusable at the moment.
My Gradle build file:
My machine is a Hyper-V virtual machine (Windows 10 x64) running Docker (20.10.5) on WSL2 (which technically becomes a nested VM). WSL2’s distro is Ubuntu 20.04.
Desperately awaiting a release version with these fixes included (Jenkins here).
@aguibert FYI I just submitted https://github.com/testcontainers/testcontainers-java/pull/2930 that should fix eager resolve of
LazyFuture
fromRemoteDockerImage#toString
(that is triggered fromGenericContainer#toString
, for example). It is unrelated to the Ryuk problem but seems to be a miss from #2558BTW from the stacktrace, it looks like you’re using a version that is older that 1.14.x, consider updating.
Affected by this using version 1.13.0