-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to configure Testcontainers to work with Colima as container runtime? #5034
Comments
Have you tried by using the
The Testcontainers docs show some other options to configure the Docker Host. |
Yes, I have tried that as well, and I get a different error that I can't comprehend. With this:
and with this:
With either of the above options, I get the same result:
Thus, using the environment variable that you suggest changes the game a bit, but there's still a missing connection. The article you linked then also links to a full suite of other |
Just in case this additional info is useful, here are the details when i inspect the two docker contexts that are registered on my workstation.
|
@codingdiscer The Testcontainers logs you shared would indicate, that
is not in effect. We can see it from this line:
We had configured a conceptually similar setup on WSL yesterday and it worked: Currently, I can only think of a typo or maybe having the environment variable set in another session, can you please double-check? |
After a couple of adjustments, I get a new error message. I also found that I had been previously suppressing the debug logs for a particularly chatty package ( I also added these (groovy) info statements to show the JVM was able to read the environment variables.
|
I just now see that you are using |
Just to pile on, I am having what might be the same issue, using colima on mac, after having switched off docker-desktop but do not have sudo rights to symlink the socket to the colima one. with the following code in a test:
and setting
I am getting:
setting the DOCKER_HOST helped to get past |
I have the same problem w/colima, and I got it working by also disabling Ryuk, i.e. using docker context use colima |
The problem is most likely that Ryuk needs the docker socket endpoint from inside the Colima VM. Setting the environment variable |
|
I can confirm that this works - meaning setting only these 2 env vars (and not messing with Ryuk at all):
Thank you @benhexagon for the suggestion, and @kiview for the follow-ups. |
Thanks for confirming @codingdiscer, very happy that we could make your use case work! 🙌 Should we close this issue in this case? We have identified a working configuration for your setup, but the title of the issue is still correct since Testcontainers is currently not Docker context aware. I'd be inclined to change the title accordingly and close this issue, if this is okay for you 🙂 |
Yes, this issue can be closed. Go ahead and update the title as you see fit to better represent the issue, and to help others find the solution. |
@kiview Agreed, it is only a temporary workaround to disable it. Seem to work now. Thanks. |
@kiview
|
@vasste Sorry, but I don't get the context of your comment. |
I tried all suggested solution under MacOS and they don't work. |
Are you specifically talking about using |
Testcontainers with Colima. |
In this case, the code snippet you have posted is unrelated and there must be some other issue with your setup. See this comment for a working example config from the Testcontainers side: |
It doesn't work under MacOS unfortunately. |
That's what |
It's used as |
It seems that I was wrong and the problem is in permission because I wasn't able to run the testcontainers/ryuk:0.3.3 goroutine 1 [running]: |
Yes, that is likely to occur when bind-mounting a volume (e.g. a file) that is owned by non-root users. The reason is that the owner user IDs and owner group IDs of such files within the Docker container remain the same as in the host OS. They might, however, represent different users and different groups. Files owned by root are unaffected by this because its user ID is typically 0 everywhere. |
Hey 👋 During my adventure of setting up a working environment to run testcontainers on macOS using a Lima-VM based solution, I stumbled upon this issue. It helped me figure out some details. Therefore, I want to share my findings, so that others in the same situation can try for themselves. Setup with Colima + testcontainersDuring my tests, I couldn't make
Setup with Lima-VM + testcontainersThis one was a bit trickier. Based on the thought process behind the colima setup, I searched how I could get an IP as I had with colima.
networks:
- lima: bridged
There might be better ways of setting up Lima-VM, but colima setup was easier and good enough for me, so I stopped there. @kiview I'm not sure if this is the best place to share info like this. If not, sorry in advance 🙏 |
I got things to finally work using the method @tiagomota described – i.e., in addition to what the docs are saying, I needed to also run colima with
|
I have a Mac m2. I followed the guide above: installed colima, started colima with
But I always got (with or without the symlink mentioned above):
Please let me know what else I should do.
Thanks |
Unsetting
|
@datavisortedyu - the stacktrace that you posted might not indicate the root cause error that we need to solve. I'm not familiar with the Are there any other messages in the logs that might give us more info? I'll note that the exception message that you posted isn't the same as the message at the start of this thread. Testcontainers is (more-or-less) a wrapper around Docker. My point there is to ask this question - are you able to get your image running via Docker commands from the command line directly from your workstation (either via a simple Dockerfile or a docker-compose file) ? Lastly, I might need to take back my suggestion of changing your |
With alternate Thanks for the response. |
With freshly installed colima and testcontaines-1.17.5, I'm able to run tests by setting these environment variables:
But I'm getting a bunch of warnings in the logs:
Not sure what to do with that. |
Documentation has been updated. Also, Testcontainers Desktop with embedded runtime works OOTB with Testcontainers |
Starting colima with |
This issue seems to persist, at least in my M2 machine. I am using the 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" Running the test I keep getting:
I tried disabling Ryuk as previously suggested and that allows the container to start. However the container startup fails. Error
|
I have the same problem from time to time within Intellij. After restarting Intellij, it works as expected. I guess it is related to updated environment variables which are not picked up by Intellij. |
Same problem since this week with command ➜ ~ colima ls -j
{"name":"default","status":"Running","arch":"aarch64","cpus":2,"memory":2147483648,"disk":64424509440,"runtime":"docker"} ✅ It works when I start with commande ➜ ~ colima ls -j
{"name":"default","status":"Running","arch":"aarch64","cpus":2,"memory":2147483648,"disk":64424509440,"address":"192.168.106.2","runtime":"docker"} After running # Network configurations for the virtual machine.
network:
# Assign reachable IP address to the virtual machine.
# NOTE: this is currently macOS only and ignored on Linux.
# Default: false
address: false |
Is there a way to run testcontainers desktop runtime without signing up? |
after reading the issue and applying suggested solutions above and according to documentation starting colima with the following command
is leading to connection refused on running IT tests in IntelliJ
on M3 Pro Sonoma 14.4.1 |
These env vars worked for me locally:
Apple MacBook Pro M2 Max Sonoma 14.4.1 |
After switching back to 0.6.8 via homebrew and
and docker context use colima without starting docker client manually did work and now i'm able to start container within colima |
This enables seamless integration with alternative Docker engines such as [Colima][1] or [OrbStack][2]. Without this change it requires a [specific configuration][3] that's far from obvious to figure out. [1]: https://github.com/abiosoft/colima [2]: https://orbstack.dev [3]: testcontainers/testcontainers-java#5034 (comment)
In the move away from paid Docker Desktop and towards alternatives, my organization has selected Colima as our official Docker engine for desktop development. After installing Colima via Homebrew on my mac, I'm able to run all my favorite docker commands as-is.
Colima sets up a new docker context, and sets itself as the active context:
As shown in the output above, there is still a
default
entry, and it points tounix:///var/run/docker.sock
. However, I can see that no such file exists at that location:I noticed a problem when using Testcontainers 1.16.3 (and earlier versions) where Testcontainers can't find the "active" docker socket. Here are the logs when running a test case that tries to spin up a
DockerComposeContainer
with the scenario that I describe above:I found a work-around that solves this problem, but it isn't a global solution. I have sudo rights on my workstation, so when I manually create a symlink from
/var/run/docker.sock
to/Users/ddowma/.colima/docker.sock
, it works.Thus, after running this command:
Then my test case works fine. Here's the relevant output from the test case immediately after creating that symlink that shows the docker environment startup working as expected. I filtered some DEBUG statements that didn't add value, but left all the INFO statements in.
What I glean from this exercise is that Testcontainers is taking the
default
docker context (or maybe not checking at all), and isn't looking at the active context. If my assessment of the problem is correct, can that situation be addressed?The text was updated successfully, but these errors were encountered: