Skip to content
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

Podman support? #73

Open
kianmeng opened this issue Jan 10, 2024 · 13 comments
Open

Podman support? #73

kianmeng opened this issue Jan 10, 2024 · 13 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@kianmeng
Copy link
Contributor

While running the test, I have noticed this library only support Docker. Are there any plans to support https://github.com/containers/podman?

$ mix test
Compiling 34 files (.ex)
** (EXIT from #PID<0.99.0>) an exception was raised:
    ** (CaseClauseError) no case clause matching: {:error, [docker_socket_path: :docker_socket_not_found]}
        (testcontainers 1.6.0) lib/connection/connection.ex:34: Testcontainers.Connection.docker_base_url/0
        (testcontainers 1.6.0) lib/connection/connection.ex:16: Testcontainers.Connection.get_connection/1
        (testcontainers 1.6.0) lib/testcontainers.ex:33: Testcontainers.setup/1
        (stdlib 5.2) gen_server.erl:980: :gen_server.init_it/2
        (stdlib 5.2) gen_server.erl:935: :gen_server.init_it/6
        (stdlib 5.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
@jarlah
Copy link
Member

jarlah commented Jan 12, 2024

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.

@kiview
Copy link
Member

kiview commented Jun 27, 2024

@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.

@kianmeng
Copy link
Contributor Author

@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
...

@jarlah
Copy link
Member

jarlah commented Jul 1, 2024

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

@jarlah jarlah added bug Something isn't working good first issue Good for newcomers labels Jul 1, 2024
@jarlah
Copy link
Member

jarlah commented Jul 1, 2024

adding good first issue, since this is a localized issue and can be solved in isolation.

@jarlah jarlah self-assigned this Jul 11, 2024
@jarlah
Copy link
Member

jarlah commented Jul 11, 2024

@jarlah
Copy link
Member

jarlah commented Jul 11, 2024

we only support docker host urls that can reply to /_ping which propably doesnt include rootless podman urls

@jarlah jarlah removed their assignment Sep 24, 2024
@jarlah jarlah removed the good first issue Good for newcomers label Sep 24, 2024
@jarlah jarlah added the help wanted Extra attention is needed label Nov 6, 2024
@jarlah
Copy link
Member

jarlah commented Nov 10, 2024

@kianmeng can you test again now? i have implemented support for rootless docker.
use
{:testcontainers, "~> 1.11", only: [:dev, :test], runtime: false}

@jarlah
Copy link
Member

jarlah commented Nov 10, 2024

In my nixos environment i have a DOCKER_HOST env var pointing to the rootless docker socket. You need to make a similar for podman.

@jarlah
Copy link
Member

jarlah commented Nov 11, 2024

I will try to test with podman too. At work. Since i use redhat with podman there

@jarlah
Copy link
Member

jarlah commented Nov 11, 2024

it still doesnt work on podman

$ echo $DOCKER_HOST
unix:///run/user/1199047593/podman/podman.sock

$ mix testcontainers.test

12:08:02.820 [error] backend port not found: :inotifywait

** (EXIT from #PID<0.93.0>) {:error, {:http_error, 400}}

not a good error message tbh, but i will look into it .. because it works perfectly on normal docker setup both rootless and root

@jarlah
Copy link
Member

jarlah commented Nov 11, 2024

a myriad of failures ..

  1. "X-Registry-Auth" is not supported/working. So removed it temporarely, enabling tests to continue

  2. exec start not working aka command wait strategy with commands in container

** (MatchError) no match of right hand side value: {:error, %Tesla.Env{method: :post, url: "http+unix://%2Frun%2Fuser%2F1199047593%2Fpodman%2Fpodman.sock/v1.41/exec/c822f854506ff8ed415bf30cc72e2b1fa8053c3b3760c8cbeed2c6be3edb7e92/start", query: [], headers: [{"api-version", "1.41"}, {"content-type", "application/json"}, {"libpod-api-version", "4.9.4-rhel"}, {"server", "Libpod/4.9.4-rhel (linux)"}, {"x-reference-id", "0xc000c6e9b0"}, {"date", "Mon, 11 Nov 2024 13:37:55 GMT"}, {"content-length", "120"}], body: "{"cause":"invalid argument","message":"must provide at least one stream to attach to: invalid argument","response":500}\n", status: 500, opts: [], module: Tesla, client: %Tesla.Client{fun: nil, pre: [{Tesla.Middleware.BaseUrl, :call, ["http+unix://%2Frun%2Fuser%2F1199047593%2Fpodman%2Fpodman.sock/v1.41"]}, {Tesla.Middleware.Headers, :call, [[{"user-agent", "tc-elixir/1.11.3"}]]}, {Tesla.Middleware.EncodeJson, :call, [[engine: Jason]]}], post: [], adapter: {Tesla.Adapter.Hackney, :call, [[recv_timeout: 300000]]}}}, %Testcontainers.CommandWaitStrategy{command: ["redis-cli", "PING"], timeout: 60000, retry_delay: 200}}

  1. Issue with port binding

    ** (MatchError) no match of right hand side value: {:error, {:failed_to_start_container, %DockerEngineAPI.Model.ErrorResponse{message: "rootlessport listen tcp 0.0.0.0:2181: bind: address already in use"}}}

@jarlah
Copy link
Member

jarlah commented Nov 11, 2024

but hey

82 tests, 12 failures

it works in general :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants