Testcontainers cannot start the Ryuk container when Docker runs on Colima
tests fail when Testcontainers creates its testcontainers/ryuk containerShort answer
Testcontainers does not find Colima's Docker socket the way it finds Docker Desktop's. Start Colima with a network address and set the three variables the Testcontainers docs list: DOCKER_HOST to the Colima socket, TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE, and TESTCONTAINERS_HOST_OVERRIDE. Then rerun the tests.
Fix it fast
1Find out which cause you have
Check what the shell sees. If DOCKER_HOST is empty, the test process falls back to its default strategies, not to Colima.
echo "$DOCKER_HOST" ls ~/.colima/default/docker.sock2Match what you see, then jump to its fix
What does the error look like?
tests fail when Testcontainers creates its testcontainers/ryuk containerdocker ps works in the terminal but the same daemon is not found from the test JVMeverything works on Docker Desktop and breaks after switching to Colima
Cause 1 of 2
DOCKER_HOST does not point at the Colima socket
1Check
Testcontainers tries environment variables first: DOCKER_HOST, DOCKER_TLS_VERIFY and DOCKER_CERT_PATH. If DOCKER_HOST is unset it uses defaults that do not know about Colima.
env | grep DOCKER
ls -l ~/.colima/default/docker.sock2Fix
Point DOCKER_HOST at the Colima socket in the shell or IDE run configuration that starts the tests.
export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock"3Verify
docker ps answers from the same shell, then run the tests from it.
docker psConfirmed by java.testcontainers.org
Cause 2 of 2
Colima started without a network address, and the override variables are missing
1Check
The Testcontainers docs for Colima ask for colima start --network-address, and for TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE and TESTCONTAINERS_HOST_OVERRIDE as well as DOCKER_HOST.
colima ls -j2Fix
Restart Colima with a network address and export the three variables from the Testcontainers page. This needs jq for reading the address.
colima stop
colima start --network-address
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export TESTCONTAINERS_HOST_OVERRIDE=$(colima ls -j | jq -r '.address')
export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock"3Verify
Run the test class again from the same shell.
./gradlew testConfirmed by java.testcontainers.org
How do I stop it coming back?
- Put the three exports in the shell profile or in the IDE run configuration, so tests do not depend on how they were started.
- Run docker ps in the same environment as the tests before you debug Testcontainers itself.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
The Java SDK finds no AWS credentials on an EC2 instance or in a container on it
InstanceProfileCredentialsProvider()
The SDK walks a fixed list of credential sources and the EC2 instance role is the last one.
3 causes, each with a fixServers
docker build stops at COPY because the file is not in the build context
ERROR: failed to solve: failed to compute cache key:
COPY can only read files that are inside the build context, the folder you pass to docker build.
3 causes, each with a fixServers
Docker build fails to resolve the openjdk slim-buster base image
failed to resolve source metadata for docker.io/library/openjdk:21-slim-buster
The tag you named does not exist any more.
2 causes, each with a fixServers
A Java container dies at start with 'insufficient memory' or errno=12
os::commit_memory failed; error='Not enough space' (errno=12)
The JVM asked the operating system for more memory than the container is allowed to use.
3 causes, each with a fixServers
MongoDB says Authentication failed from a Java app against a Docker container
MongoCommandException: Command failed with error 18 (AuthenticationFailed): 'Authentication failed.' on server localhost:27017
Error 18 means MongoDB found no matching user in the database it checked.
4 causes, each with a fixServers
Testcontainers fails with Could not connect to Ryuk at localhost
docker ps shows a testcontainers/ryuk container while the test fails
Ryuk is the helper container Testcontainers starts to clean up after tests.
3 causes, each with a fix