docker alpine jdk chromium selenium:Could 没有启动新的 session.Possible 原因是远程服务器地址无效或浏览器启动失败

docker alpine jdk chromium selenium:Could not start a new session.Possible causes are invalid address of the remote server or browser start-up failure

我的 java 驱动程序片段代码(当然我有更多标准选项,如 --headless 等):

String chromeDriverLinux = "./config/driver/chromedriver-linux/chromedriver";   // 
here is file in target version (93.0.4577.63 for docker)
final ChromeOptions options = new ChromeOptions();
options.addArguments("--remote-debugging-port=9222");

/* commented on non-docker version - i think it may be needed by docker version
when i execute it on local non-docker ver i received error: 
Caused by: java.util.concurrent.ExecutionException: 
java.util.concurrent.TimeoutException: Request timeout to localhost/127.0.0.1:21933 
after 180000 ms
*/ 
options.addArguments("--remote-debugging-address=0.0.0.0");   

options.setBinary("/usr/bin/chromium-browser");
ChromiumDriver driver = null;
driver = new ChromeDriver(options);     // here is exception

应用程序异常日志:

driver exception: 
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. 
Possible causes are invalid address of the remote server or browser start-up failure.
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:565) ~ 
[selenium-remote-driver-4.0.0-rc-1.jar!/:?]
...
Caused by: org.openqa.selenium.WebDriverException: Driver server process died 
prematurely.
Build info: version: '4.0.0-rc-1', revision: 'bc5511cbda'
System info: host: '5c0bff50d486', ip: '172.17.0.2', os.name: 'Linux', os.arch: 
'amd64', os.version: '5.13.0-27-generic', java.version: '11.0.14'
Driver info: driver.version: ChromeDriver

pom.xml:

        <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>${selenium.version}</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium.version}</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>${selenium.version}</version>
    </dependency>


    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-devtools</artifactId>
        <version>${selenium.version}</version>
    </dependency>

Docker 文件:

FROM azul/zulu-openjdk-alpine:11

RUN addgroup -S spring && adduser -S spring -G spring
RUN mkdir -p config/driver/chromedriver-linux
RUN find config/driver/chromedriver-linux/ -type d -exec chmod 0777 {} \;
RUN find config/driver/chromedriver-linux/ -type f -exec chmod 777 {} \;

ADD config/ /config/
RUN chmod 0777 /config/driver/chromedriver-linux/chromedriver

RUN apk update && apk add --no-cache bash \
alsa-lib \
at-spi2-atk \
atk \
cairo \
cups-libs \
dbus-libs \
eudev-libs \
expat \
flac \
gdk-pixbuf \
glib \
libgcc \
libjpeg-turbo \
libpng \
libwebp \
libx11 \
libxcomposite \
libxdamage \
libxext \
libxfixes \
tzdata \
libexif \
udev \
xvfb \
zlib-dev \
chromium \
chromium-chromedriver \
&& rm -rf /var/cache/apk/* \
/usr/share/man \
/tmp/*


USER spring:spring

ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} bot-app.jar
ENTRYPOINT ["java","-jar","/bot-app.jar"]
EXPOSE 9223 9222

运行 docker文件:

sudo docker build --no-cache=True -t bot-image .

运行容器:

sudo docker network create app_bot_network
sudo docker run --network app_bot_network -p 8080:8080 -p 4444:4444 -p 9223:9222 -p 6900:5900 -it --rm --name bot-container bot-image:latest

我在开始前还关闭了防火墙和 vpn docker。

所以,错误是什么问题: SessionNotCreatedException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。 ?

它不是驱动程序问题版本,docker 端口设置,网络...?或者执行浏览器?

问候

我花了一些时间并找到了解决方案。

我更改了 java 代码 来自:

String chromeDriverLinux = "./config/driver/chromedriver-linux/chromedriver";

(这里是我自己复制的最相似的ChromeDriver 93.0.4577.63版本)

至:

String chromeDriverLinux = "/usr/bin/chromedriver";

(这里我的驱动版本和dockerfile apk安装的浏览器完全一样 93.0.4577.82)

我有奇怪的错误异常而不是那个驱动版本是杂那个浏览器版本