Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dockerfile with chromedriver
# See https://codeship.com/documentation/docker/browser-testing/
FROM myapp:base
# 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
# Set up the Chrome PPA
RUN wget -q -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 2.19
ENV CHROMEDRIVER_DIR /chromedriver
RUN mkdir $CHROMEDRIVER_DIR
# Download and install Chromedriver
RUN wget -q --continue -P $CHROMEDRIVER_DIR "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
RUN unzip $CHROMEDRIVER_DIR/chromedriver* -d $CHROMEDRIVER_DIR
# Put Chromedriver into the PATH
ENV PATH $CHROMEDRIVER_DIR:$PATH
@dnlserrano

This comment has been minimized.

Copy link

dnlserrano commented Jun 27, 2017

Thanks man! 👍

@ORESoftware

This comment has been minimized.

Copy link

ORESoftware commented Nov 6, 2017

why not use the default path of

/usr/bin/google-chrome

?

@xxholyChalicexx

This comment has been minimized.

Copy link

xxholyChalicexx commented Dec 3, 2018

FROM myapp:base...... which image are you using?

@vladdoster

This comment has been minimized.

Copy link

vladdoster commented Jan 5, 2019

FROM myapp:base...... which image are you using?

I think it is just a placeholder for an image that supports the commands!

@simonneutert

This comment has been minimized.

Copy link

simonneutert commented Mar 29, 2019

you, sir, deserve an award for this! 🎉

@maram2012

This comment has been minimized.

Copy link

maram2012 commented Aug 21, 2019

pull access denied for myapp, repository does not exist or may require 'docker login'
I got that error , what should i do ?

@tomreitsma

This comment has been minimized.

Copy link

tomreitsma commented Sep 1, 2019

@maram2012 it's a placeholder.. you should provide your own image base

@JoaRiski

This comment has been minimized.

Copy link

JoaRiski commented Jan 30, 2020

I adapted this to fetch the latest version of chrome driver appropriate for the chrome installation, rather than having a fixed value. Here's the snippet I use for installing:

RUN apt-get update && \
    apt-get install -y gnupg wget curl unzip --no-install-recommends && \
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
    echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list && \
    apt-get update -y && \
    apt-get install -y google-chrome-stable && \
    CHROMEVER=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*") && \
    DRIVERVER=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROMEVER") && \
    wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$DRIVERVER/chromedriver_linux64.zip" && \
    unzip /chromedriver/chromedriver* -d /chromedriver
@Benji4

This comment has been minimized.

Copy link

Benji4 commented Feb 25, 2020

The mkdir command needs option -p:
RUN mkdir -p $CHROMEDRIVER_DIR

The Chromedriver must be made executable:
RUN chmod +x $CHROMEDRIVER_DIR/chromedriver

Chromedriver might need these packages:
RUN apt-get install libxi6 libgconf-2-4 -y

Also possibly, chrome might need to be run with option --no-sandbox, but not sure; might be a security issue.

Thank you for the Dockerfile! Really made my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.