docker run <ryuk_image_id>
fails because of the following error:
panic: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
I have set up the following in ~/.zprofile (I am using Mac):
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock"
export TESTCONTAINERS_HOST_OVERRIDE=$(colima ls -j | jq -r '.address'))
and started colima:
colima start --network-address
Notice that I cannot use Docker desktop
I am trying to use Colima and I am expecting that Ryuk is pointing to:
${HOME}/.colima/default/docker.sock
Also .testcontainers.properties has the following configuration:
docker.client.strategy=org.testcontainers.dockerclient.UnixSocketClientProviderStrategy
It's not completely clear what's happening from the description, i.e. who is running
docker run— is it you or TestContainers during app tests run? Log snippets would be helpful. But the error message you're getting (Cannot connect to the Docker daemon at unix:///var/run/docker.sock) makes me think that yourDOCKER_HOSTenvironment variable is not picked up by the process which is interacting with docker.First I'd check
docker context lsoutput in a brand new terminal window. IfDOCKER_HOSTis set, you'll see something like this:If instead you see the default
unix:///var/run/docker.sockendpoint under thedefaultprofile, then I guess something is wrong with the way you setDOCKER_HOSTin your environment.If that's not it, then maybe something is wrong with the way you launch your process? Are you running it from an IDE? If so, have you restarted your IDE after setting up your exports?
Couple more thoughts based on your question:
Looks like you started colima after setting up the environment variables. Then probably you didn't get
TESTCONTAINERS_HOST_OVERRIDEright in that terminal session because colima wasn't started yet and hence there was no address yet. Anyway, tryecho $TESTCONTAINERS_HOST_OVERRIDEand see if there's a valid IP in there.I don't think you need to override
docker.client.strategy, at least I didn't have to with the same setup.Alternative setup
Although the setup you're using is described in the official colima docs, I use a different setup which I consider to be more simple. All you need is to setup a symbolic link like this:
You don't need to setup the
DOCKER_HOST,TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE,TESTCONTAINERS_HOST_OVERRIDEenv vars.Couple of caveats though:
colima statusfor that.TESTCONTAINERS_HOST_OVERRIDEif you run your colima with--network-addressflag. Note: if you ever used the--network-addressflag, it persists even if you restart colima without it (it is saved in.colima/default/colima.yaml), so you either need to docolima deleteor manually unset it if you no longer require network address.