Привет! Я автоматизирую тестирование наших узловых приложений и использую jenkins для этого.Поскольку мы проводим тестирование браузера, я использую jenkins, selenium, google chrome и chromedriver на моей локальной машине.
Я хочу перевести это в файл Docker, и мой файл Docker выглядит следующим образом.
# Getting jenkins image
FROM jenkins/jenkins:2.176.3
# Changing the user to root
USER root
ENV TZ=America/New_York
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# installing chrome driver
RUN apt-get update && apt-get -qq -y install curl
RUN apt-get install ca-certificates
# We need wget to set up the PPA and xvfb to have a virtual screen and unzip to install the Chromedriver
RUN apt-get install -y wget xvfb unzip
RUN curl -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
# Update the package list and install chrome
RUN apt-get update -y
RUN apt-get install -y google-chrome-stable
# Set up Chromedriver Environment variables
ENV CHROMEDRIVER_VERSION 76.0.3809.12
ENV CHROMEDRIVER_DIR /chromedriver
RUN mkdir $CHROMEDRIVER_DIR
RUN curl http://chromedriver.storage.googleapis.com/76.0.3809.12/chromedriver_linux64.zip -o /chromedriver/chromedriver_linux64.zip -J -L
RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR
RUN chmod 777 -R /chromedriver
# Put Chromedriver into the PATH
ENV PATH $CHROMEDRIVER_DIR:$PATH
USER jenkins
Это происходит успешно, и когда я запускаю Docker и SSH в работающий образ, и я набираюgoogle-chrome Я получаю следующую ошибку
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
Trap / breakpoint trap
Когда я запускаю свои тесты npm в Jenkins, я получаю следующую ошибку, что Chrome упал
(node:316) UnhandledPromiseRejectionWarning: WebDriverError: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:550:15)
at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:563:13)
at Executor.execute (node_modules/selenium-webdriver/lib/http.js:489:26)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:316) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Мой вопрос:
Что-то не так с моим файлом докера?
Есть ли что-то, чего мне здесь не хватает?