Forked from Faq/gist:8821c5fd18dd01da4f80d7435158096d
Last active
February 20, 2024 21:25
-
-
Save spikegee/ae044abdfaad8431f5f27114f63ea1e8 to your computer and use it in GitHub Desktop.
Install chrome & chromedriver for Docker image 2022
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Source: https://gist.github.com/varyonic/dea40abcf3dd891d204ef235c6e8dd79 | |
Change log: | |
1. replaced "dl-ssl.google.com" with "dl.google.com" according https://www.google.com/linuxrepositories/ | |
2. replaced "apt-key" as "Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8))." | |
3. use https | |
Julien updates: | |
1. since this does not work for recent version of chrome, chrome version must be selected rather than the latest version taken. | |
I had to match a version of the chrome driver here: https://chromedriver.storage.googleapis.com/ | |
with an available ubuntu update here https://www.ubuntuupdates.org/pm/google-chrome-stable | |
where I manually copied the link to the .deb | |
To check: in what way is it preferrable to use an official selenium image? | |
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:latest | |
---- | |
# Use an official Python runtime as a parent image | |
FROM python:3.12.2-slim-bullseye | |
# Install latest Chrome | |
RUN set -ex | |
RUN apt-get update; \ | |
apt-get install -y gnupg wget curl unzip --no-install-recommends; | |
RUN CHROME_VERSION=112.0.5615 | |
# fix missing dependencies | |
RUN PACKAGE=http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg_112.0.5615.49-0ubuntu0.18.04.1_amd64.deb | |
RUN wget --no-verbose -O /tmp/package.deb ${PACKAGE}; \ | |
dpkg -i /tmp/package.deb; \ | |
rm /tmp/package.deb | |
RUN PACKAGE=http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg-extra_112.0.5615.49-0ubuntu0.18.04.1_amd64.deb | |
RUN wget --no-verbose -O /tmp/package.deb ${PACKAGE}; \ | |
dpkg -i /tmp/package.deb; \ | |
rm /tmp/package.deb | |
RUN PACKAGE=http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-browser_112.0.5615.49-0ubuntu0.18.04.1_amd64.deb | |
RUN wget --no-verbose -O /tmp/package.deb ${PACKAGE}; \ | |
apt install /tmp/package.deb; \ | |
rm /tmp/package.deb | |
RUN apt --fix-broken install | |
# Install matching chrome driver | |
RUN CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION") | |
RUN wget -q --continue -P /chromedriver "https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip" | |
RUN unzip /chromedriver/chromedriver* -d /usr/local/bin/ | |
---- | |
# To check it after (chrome and chromedriver versions will be the same): | |
$ docker run --rm -it put_docker_image_name_here bash | |
$ google-chrome --version or chromium-browser --version depending on which version was installed | |
$ chromedriver -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment