3

With the license change for Docker Desktop on Windows, I'm looking for an alternative. Podman + WSL2 seems to do the trick for me. Except for Testcontainers in my Quarkus tests.

I'm able to run my tests within WSL2 by starting podman system service in WSL2 (podman system service -t 0 tcp:localhost:8880) and setting the DOCKER_HOST env var (DOCKER_HOST=tcp://localhost:8880).

Now this works, but isn't really what I need, since at my company we develop in VSCode, IntelliJ and Eclipse. I'd like to be able to run the tests from within those IDE's. Is there any way to pass the podman uri (from WSL) to my IDE in Windows while running Quarkus tests?

If anyone would know any other docker desktop alternatives that work with TestContainers, that would be awesome as well. I have tried Rancher Desktop, but it gets stuck and the tests eventually time out.

kava
  • 31
  • 3

3 Answers3

2

You have to install podman-remote packages on your windows host machine, then configure it to use tcp://WSL2_IP:8880 (podman documentation) and finally make an alias for the program docker -> podman.exe.

Now you are able to run docker commands as usual... docker ps docker run etc. But it does not mean that all tools will work out of the box. You have to tune it.

For example for testcontainers you have to set env variables on host machine:

PowerShell

[System.Environment]::SetEnvironmentVariable("DOCKER_HOST", "tcp://WSL2_IP:8880", [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("TESTCONTAINERS_CHECKS_DISABLE", "True", [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("TESTCONTAINERS_RYUK_DISABLED", "True", [System.EnvironmentVariableTarget]::User)

P.S. All that kind of variables were set for you by docker, but from now you have to do it by yourself.

befna.com
  • 21
  • 1
  • So far so good, thank you :) Only now I have an issue with testcontainers using environment variables. It works with containers not having any environment vairables, but if a container is started with 'withEnv', the test crashes with: `Status 500: {"cause":"incorrect volume format, should be [host-dir:]ctr-dir[:option]","message":"fill out specgen: tcp://localhost:8880:/var/run/docker.sock:rw: incorrect volume format, should be [host-dir:]ctr-dir[:option]","response":500}` – kava Jan 13 '22 at 09:56
  • Previous issue was actually incorrect setup, redid it and it worked – kava Jan 13 '22 at 12:39
0

We ran the testcontainers-java tests using various solutions for Docker.

I don't know if running in WSL changes a lot compared to the Windows only setup. In general, Testcontainers doesn't rely only on the CLI commands only and works best with compatible Docker environments. Based on the findings in that experiment, you can try minikube.

Oleg Šelajev
  • 3,530
  • 1
  • 17
  • 25
0

enter image description hereTake IntelliJ for example, you can set DOCKER_HOST env var by "Run/Debug Configurations" and it works perfectly.