Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kenfehling
Last active March 23, 2019 12:02
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save kenfehling/d37bd6149bbabf1e3bdf09b0882ca044 to your computer and use it in GitHub Desktop.
Save kenfehling/d37bd6149bbabf1e3bdf09b0882ca044 to your computer and use it in GitHub Desktop.
Docker: Ubuntu 16.04 with Node 6.10.2, Selenium Standalone, Chrome Headless
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
apt-transport-https \
openjdk-8-jre-headless \
curl \
xz-utils \
unzip \
bzip2 \
wget \
&& rm -rf /var/lib/apt/lists/*
#==========
# Chrome
#==========
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update -qqy \
&& apt-get -qqy install google-chrome-unstable \
&& rm /etc/apt/sources.list.d/google-chrome.list \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN mkdir /data
#==========
# Selenium
#==========
RUN mkdir -p /opt/selenium \
&& wget --no-verbose https://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar -O /opt/selenium/selenium-server-standalone.jar
#==================
# Chrome webdriver
#==================
ARG CHROME_DRIVER_VERSION=2.29
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
ENV NPM_CONFIG_LOGLEVEL info
ENV NODE_VERSION 6.10.2
#==========
# NodeJS
#==========
RUN curl -SLO https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz \
&& tar -xJf node-v$NODE_VERSION-linux-x64.tar.xz -C /usr/local --strip-components=1 \
&& rm node-v$NODE_VERSION-linux-x64.tar.xz \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
# Following line fixes
# https://github.com/SeleniumHQ/docker-selenium/issues/87
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
ENTRYPOINT java -jar /opt/selenium/selenium-server-standalone.jar
EXPOSE 4444
@kenfehling
Copy link
Author

@Dayjo
Copy link

Dayjo commented Dec 18, 2018

Thank you thank you thank you! Docker really can be a pain :D

@nishantyedla
Copy link

nishantyedla commented Feb 20, 2019

Did this work for you guys?I get unable to create new session on the selenium page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment