【问题标题】:How to build a docker image for java and chromedriver?如何为 java 和 chromedriver 构建 docker 镜像?
【发布时间】:2019-03-11 17:08:56
【问题描述】:

我想为 java 和 chromedriver 构建一个 docker 映像。这是我的 dockerfile。


FROM java:8
MAINTAINER LIU JICHUN jliu666@hotmail.com
ENV TZ Asia/Shanghai

RUN echo "deb http://mirrors.ustc.edu.cn/debian/ jessie main contrib non-free" > /etc/apt/sources.list \
    && echo "deb-src http://mirrors.ustc.edu.cn/debian/ jessie main contrib non-free" >> /etc/apt/sources.list \

    && echo "deb http://mirrors.ustc.edu.cn/debian/ jessie-updates main contrib non-free" >> /etc/apt/sources.list \
    && echo "deb-src http://mirrors.ustc.edu.cn/debian/ jessie-updates main contrib non-free" >> /etc/apt/sources.list \

    && echo "deb http://mirrors.ustc.edu.cn/debian/ jessie-backports main contrib non-free" >> /etc/apt/sources.list \
    && echo "deb-src http://mirrors.ustc.edu.cn/debian/ jessie-backports main contrib non-free" >> /etc/apt/sources.list \

    && echo "deb http://mirrors.ustc.edu.cn/debian-security/ jessie/updates main contrib non-free" >> /etc/apt/sources.list \
    && echo "deb-src http://mirrors.ustc.edu.cn/debian-security/ jessie/updates main contrib non-free" >> /etc/apt/sources.list \
    && apt-get update \
    && apt-get install -y libxss1 libappindicator1 libindicator7 xvfb unzip fonts-liberation libappindicator3-1 libatk-bridge2.0-0 libgtk-3-0 lsb-release xdg-utils\
    && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
    && dpkg -i google-chrome*.deb \
    && apt-get install -f \
    && wget -N https://chromedriver.storage.googleapis.com/2.42/chromedriver_linux64.zip \
    && unzip chromedriver_linux64.zip \
    && chmod +x chromedriver \
    && mv -f chromedriver /usr/local/share/chromedriver \
    && ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver \
    && ln -s /usr/local/share/chromedriver /usr/bin/chromedriver \

但是当我运行 chromedriver 时,出现如下错误:


Starting ChromeDriver 2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac) on port 24557
Only local connections are allowed.
[1538823654.540][SEVERE]: bind() returned an error, errno=99: Cannot assign requested address (99)
2018-10-06 19:00:54.747  INFO 1 --- [ null to remote] o.o.selenium.remote.ProtocolHandshake    : Detected dialect: OSS

【问题讨论】:

  • 它有效。但有错误。

标签: docker selenium-chromedriver debian-jessie


【解决方案1】:

在 google 上搜索,docker-chromedriver 存储库中似乎有一个未解决的问题,建议:

  • 安装 chrome-headless
  • 在 Dockerfile 上公开端口 9515

虽然可能是端口已打开的问题(请参阅here),但请确保该端口尚未被其他进程使用。

【讨论】:

    猜你喜欢
    • 2017-12-22
    • 1970-01-01
    • 2020-10-06
    • 2021-02-27
    • 1970-01-01
    • 1970-01-01
    • 2020-06-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多