Skip to content

Conversation

@gossi
Copy link

@gossi gossi commented Jan 22, 2026

Hello,

I'm trying to use testcontainers for an elixir project on a mac with podman. Under some conditions the stars must align for it to work, as such for me. I followed these steps here:

With all the different errors:

** (EXIT from #PID<0.94.0>) {:error, {:failed_to_create_container, %DockerEngineAPI.Model.ErrorResponse{message: "make cli opts(): making volume mountpoint for volume /var/folders/95/bfjp2z0x5l57lzbp6c047rxw0000gn/T/podman/podman-machine-default-api.sock: mkdir /var/folders/95/bfjp2z0x5l57lzbp6c047rxw0000gn/T/podman/podman-machine-default-api.sock: operation not supported"}}}
** (EXIT from #PID<0.94.0>) {:error, {:failed_to_register_ryuk_filter, :closed}}
[info] Docker host: {"http+unix://%2Fvar%2Frun%2Fdocker.sock", "unix:///var/run/docker.sock"}

[debug] Not running in docker environment, using localhost

[info] Connection refused. Retrying... Attempt 1/3

[info] Connection refused. Retrying... Attempt 2/3

[info] Connection refused. Retrying... Attempt 3/3

[info] Ryuk host refused to connect
** (EXIT from #PID<0.94.0>) {:error, :econnrefused}

the errors center around ryuk. I still dunno what that is to be fair, but I understand it as a container to assist managing other containers. Though this can lead to problems under podman(/mac). And the docs recommend to turn off ryuk with this flag:

export TESTCONTAINERS_RYUK_DISABLED=true

however, nothing changed for me. When I searched for this env var on this repo, the results were empty and I had my answer. I searched the node and java repo for that env var and they had implementations for it.

I looked into the node impl and I thought to give it a shot. I made a very stubborn form for my impl. I'd say it acts more of a poc. I run the tests, too - I had 5 timeouts. Compared to before were no tests ran at all, this is a very good improvement 😁

Also I used this fork, used it as path dep to my actual project, and could run the tests over there - yeah 🥳

I think the POC is looking quite promising. There is plenty ways to write my code changes. I dunno what would match your style (also I'm still quite fresh to elixir). I'd kindly ask you to take over my PR.

Thanks a lot.

@jarlah
Copy link
Member

jarlah commented Jan 30, 2026

well, by all means. If someone wants to do this, disable ryuk, and possibly fill up their disk with docker containers due to failed test runs or vups closed terminal, its ok i guess. I see also java library says that they actually close the containers manually in the library, and i think this does it too, Its just a security mechanism to use ryuk. ill think about it :)

@gossi
Copy link
Author

gossi commented Jan 31, 2026

Thanks for the response.

I think the main question here is: Will testcontainers work - yes or no?
And under regular podman install (with docker compatibility) it won't.

The reason being, that docker containers run as root, whereas podman doesn't. Ryuk apparently requires to be run as root. I think testcontainers might even be able to identify this and also detect if podman is running and could give advice. The possible solutions (I'm aware):

I looked into the java implementation and they actually give a warning, when they disable ryuk and it can lead to unintended behavior, that's a good thing to do. Also they try to cleanup afterwards, that seems a good idea, too - If you give me an idea where to get the DEATH_NOTE from, I can take a look at an impl.

I think first #221 shall land to bring in the property reader, then this PR can adopt to it.

@jarlah
Copy link
Member

jarlah commented Jan 31, 2026

ah death note. jvm exit. this is the best thing with java. In elixir its not possible. I think we have a plan here.

  1. Introduce a system for deactivating ryuk
  2. Log a warning message when ryuk is disabled (IO puts, ignoring log levels)
  3. Also allow for overriding via properties as mentioned.

And yes you have a fair point that the elevation needed to cleanup containers can be a real problem.

I checked the exunit macro and it properly closes the containers on happy path scenarios.

ref https://github.com/testcontainers/testcontainers-elixir/blob/main/lib/exunit.ex#L58

so, if a user uses the RYUK disabled flag, via env var or properties, the containers will quickly fill up the disk if not reusing containers (which is supported) or forgetting to stop containers after use. However, this IS a user problem and not a library problem, so I could be open for adding it in.

@jarlah
Copy link
Member

jarlah commented Jan 31, 2026

i also agree on bringing in property support as you mentioned, first

@jarlah
Copy link
Member

jarlah commented Jan 31, 2026

@gossi now you can sync and fix conflicts

@jarlah
Copy link
Member

jarlah commented Jan 31, 2026

i will definitely improve the code when your pr is merged. So near perfect might be good enough for now :)

@gossi gossi force-pushed the respect-ryuk-disable-env branch from 613b951 to bd71feb Compare January 31, 2026 19:59
@gossi
Copy link
Author

gossi commented Jan 31, 2026

Ok, I've switched to using the properties, that are now available.
I've been dropping the warning message, too.

I've checked ExUnit.Callbacks.on_exit() - which also does run, when a test fails, so I guess cleanup is happening very well already.

I did not check for the situation, that we can give advice here (I need to learn better elixir here at first I guess).

Anything else?

Copy link
Member

@jarlah jarlah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small change, and we are good. I could do it in another commit afterwards but its better to cleanup in this PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove socket: socket. Its not used anywhere. Socket is only used to register ryuk filter

@gossi
Copy link
Author

gossi commented Feb 1, 2026

Aye, pushed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants