Webdriverio客户端不会在Docker容器中启动

所以我试图在无头镀铬运行seleniumtesting。 我正在使用webdriver来启动我的客户端。 但它不工作。 我的testing卡在启动客户端,过了一段时间我收到错误消息。 下面你可以看到我是如何发起我的客户。

const client = webdriverio.remote({ desiredCapabilities: { browserName: 'chrome', chromeOptions: { args: ['--headless', '--disable-gpu'] }, binary: '/opt/google/chrome/google-chrome', }, baseUrl: CONFIG.host, logLevel: 'verbose', waitForTimeout: 3000 }) 

另外,当我运行我的docker容器(docker运行-it – cap-add = SYS_ADMIN headless-chrome / bin / bash)与下面的命令,我得到的回应。 正因为如此,我认为这不是我的二进制或我的参数的问题。

 chrome@e7b2dd3f7ac8:~$ /opt/google/chrome/google-chrome --headless --disable-gpu --dump-dom https://www.chromestatus.com 

以下是我的docker形象:

 # Base docker image FROM debian:sid LABEL name="chrome-headless" \ maintainer="Justin Ribeiro <justin@justinribeiro.com>" \ version="1.4" \ description="Google Chrome Headless in a container" # Install deps + add Chrome Stable + purge all the things RUN apt-get update && apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg \ --no-install-recommends \ && curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \ && echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \ && apt-get update && apt-get install -y \ google-chrome-stable \ --no-install-recommends \ && apt-get purge --auto-remove -y curl gnupg \ && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install -y nodejs npm git unzip RUN ln -s /usr/bin/nodejs /usr/bin/node #================== # Chrome webdriver #================== ARG CHROME_DRIVER_VERSION=2.30 RUN wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \ && rm -rf /opt/selenium/chromedriver \ && unzip /tmp/chromedriver_linux64.zip -d /opt/selenium \ && rm /tmp/chromedriver_linux64.zip \ && mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \ && chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \ && ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver # Add Chrome as a user RUN groupadd -r chrome && useradd -r -g chrome -G audio,video chrome \ && mkdir -p /home/chrome && chown -R chrome:chrome /home/chrome # Run Chrome non-privileged USER chrome WORKDIR /home/chrome ADD .npmrc .npmrc ADD package.json package.json COPY . . RUN npm install --no-optional # Expose port 9222 EXPOSE 9222 # Autorun chrome headless with no GPU ENTRYPOINT ["/bin/bash", "-c"] #ENTRYPOINT ["google-chrome-stable"] #CMD ["--headless", "--disable-gpu", "--remote-debugging-address=0.0.0.0", "--remote-debugging-port=9222" ]