# 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 |
@Amogh Katwe
did you get a solutionn ?!
Guys, this works for me.
FROM python:3.10.2-bullseye RUN apt-get update -y # 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 97.0.4692.71 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
@lane-eb Thank you
This ^^ approach will not work for the long term. If you were to install Google Chrome on most platforms today, your version would be 101.xxx.xxx.xxx -- a version 97 chromedriver won't work with today's Chrome without having to re-determine the chromedriver version and update the Dockerfile accordingly.
Currently, I do this:
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 && \
CHROME_VERSION=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*") && \
CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION") && \
wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip" && \
unzip /chromedriver/chromedriver* -d /usr/local/bin/
It has worked consistently for several months over several Chrome updates.
This ^^ approach will not work for the long term. If you were to install Google Chrome on most platforms today, your version would be 101.xxx.xxx.xxx -- a version 97 chromedriver won't work with today's Chrome without having to re-determine the chromedriver version and update the Dockerfile accordingly.
Currently, I do this:
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 && \ CHROME_VERSION=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*") && \ CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION") && \ wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip" && \ unzip /chromedriver/chromedriver* -d /usr/local/bin/
It has worked consistently for several months over several Chrome updates.
Thank You @mnaumann-plenty, saved my day.
This is up to date version what worked for me with ruby container as it sets correct path with: /usr/local/bin/
Now in container chromedriver responds to: chromedriver -v
And updated it a bit https://gist.github.com/Faq/8821c5fd18dd01da4f80d7435158096d
To achieve the proper Google Chrome/chromedriver combination, you'll want to heed the instructions on this page: https://chromedriver.chromium.org/downloads/version-selection
Basically, you'll want to get the latest Chrome and install it, then get the product version from that Chrome installation (
google-chrome -product-version
), use that version information to build the URL to get the correct chromedriver version information from chromedriver.storage.googleapis.com, allowing you to build the specific download URL for the correct chromedriver version.