Mastodon hachyterm.io

Testcontainers is a Java library to support testing database operations with Docker containers.

The library needs a working Docker context to spin up the containers.

If you use Colima/Lima as a Docker replacement, you might come across the following error:

Could not find a valid Docker environment. Please see logs and check configuration
java.lang.IllegalStateException: Could not find a valid Docker environment. Please see logs and check configuration
	at org.testcontainers.dockerclient.DockerClientProviderStrategy.lambda$getFirstValidStrategy$4(DockerClientProviderStrategy.java)

You can override the docker host detection by providing the following environment variables (in your Bash/Zsh shell):

export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export DOCKER_HOST="unix://${HOME}/.colima/docker.sock"

For Fish:

set -x TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE /var/run/docker.sock
set -x DOCKER_HOST unix://{$HOME}/.colima/docker.sock

I had to restart IntelliJ to make sure that the program picks up the changed environment.