'webdrivermanager java browser in docker wsl2 how to configure

I'm trying to setup webdrivermanager java with a chrome browser in a docker container. I have a docker daemon running on my local Windows 10 machine on WSL2. The docker daemon url should be tcp://127.0.0.1:2375.

I have version 5.1.0 of webdrivermanager.

Some sample code

WebDriverManager
        .chromedriver()
        .browserInDocker()
        .dockerDaemonUrl("tcp://127.0.0.1:2375")
        .create();

I always get the following warning: WARN io.github.bonigarcia.wdm.docker.DockerService - Docker is not available in your machine... local browsers are used instead

What is the correct setup for webdrivermanager in this case?



Solution 1:[1]

For a local Docker engine, the method dockerDaemonUrl() should not be necessary.

Solution 2:[2]

The following attempt was successful. Adding avoidDockerLocalFallback did the trick. The DockerService of WebdriverManager always tries to resolve the docker daemon locally by default but is unsuccessful in case of a docker daemon running on WSL2.

WebDriverManager
    .chromedriver()
    .browserInDocker()
    .avoidDockerLocalFallback()
    .dockerDaemonUrl("tcp://127.0.0.1:2375")
    .create();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Boni GarcĂ­a
Solution 2 Curb