Open kianmeng opened 8 months ago
My immediate thought is that this should "just work". But i suppose it suffers from the same issue as the other implementations where you have to define the docker_host env var to point to podman socket.
@kianmeng What happens if you configure Podman as proposed by @jarlah? In general, all Testcontainers libraries always expect a Docker Engine API, that's is against what we integrate and if things fail, this would be an upstream issue with Podman behaving differently than Docker.
@kiview Not working for me.
ENV:
elixir 1.16.3-otp-26 /tmp/testcontainers-elixir/.tool-versions
erlang 26.2.5 /tmp/elixir/testcontainers-elixir/.tool-versions
Steps to reproduce:
cd /tmp
git clone https://github.com/testcontainers/testcontainers-elixir
cd testcontainers-elixir
asdf local elixir 1.16.3-otp-26
asdf local erlang 26.2.5
mix deps.get
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock
mix test
Result:
...
01:01:35.747 [warning] Using docker host url: http+unix://%2Fvar%2Frun%2Fdocker.sock/v1.41
01:01:46.916 [warning] Not running in docker environment, using localhost
01:01:46.916 [warning] Testcontainers initialized
.....
01:01:47.072 [warning] Using docker host url: http+unix://%2Fvar%2Frun%2Fdocker.sock/v1.41
.............
01:01:52.574 [warning] Not running in docker environment, using localhost
01:01:52.574 [warning] Testcontainers initialized
1) test can start and stop generic container (Testcontainers.GenericContainerTest)
test/generic_container_test.exs:4
** (ExUnit.TimeoutError) test timed out after 60000ms. You can change the timeout:
1. per test by setting "@tag timeout: x" (accepts :infinity)
2. per test module by setting "@moduletag timeout: x" (accepts :infinity)
3. globally via "ExUnit.start(timeout: x)" configuration
4. by running "mix test --timeout x" which sets timeout
5. or by running "mix test --trace" which sets timeout to infinity
(useful when using IEx.pry/0)
where "x" is the timeout given as integer in milliseconds (defaults to 60_000).
code: assert {:ok, container} = Testcontainers.start_container(config)
stacktrace:
(stdlib 5.2.3) gen.erl:259: :gen.do_call/4
(elixir 1.16.3) lib/gen_server.ex:1111: GenServer.call/3
test/generic_container_test.exs:6: (test)
(ex_unit 1.16.3) lib/ex_unit/runner.ex:472: ExUnit.Runner.exec_test/2
(stdlib 5.2.3) timer.erl:270: :timer.tc/2
(ex_unit 1.16.3) lib/ex_unit/runner.ex:394: anonymous fn/6 in ExUnit.Runner.spawn_test_monitor/4
...
I think it might be test_docker_host that messes things up. It tries to do a ping to test the connection. So it would never work with podman I guess, because it doesn't work that way. I would need, or someone else, to look into how the docker host is tested in the strategy implementations. I will look into it in due time, but this could be a good hint for someone else to start working on, the method test_docker_host
adding good first issue, since this is a localized issue and can be solved in isolation.
Should port this
https://github.com/testcontainers/testcontainers-go/blob/main/internal/core/docker_rootless.go
i suppose we are only implementing the stuff we can see in
https://github.com/testcontainers/testcontainers-go/blob/main/internal/core/docker_host.go
we only support docker host urls that can reply to /_ping which propably doesnt include rootless podman urls
While running the test, I have noticed this library only support Docker. Are there any plans to support https://github.com/containers/podman?