Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install a specific version of Chrome in a Dockerfile?

Tags:

Have a Dockerfile that installs from a python image and then I need it to install a specific (not latest) version of Google Chrome.

Here's what I have:

FROM python:3.6

# Tools
RUN apt-get update \
    && apt-get install -y vim less \
    && apt-get clean

# https://github.com/SeleniumHQ/docker-selenium/blob/master/NodeChrome/Dockerfile.txt
#============================================
# Google Chrome
#============================================
# can specify versions by CHROME_VERSION;
#  e.g. google-chrome-stable=53.0.2785.101-1
#       google-chrome-beta=53.0.2785.92-1
#       google-chrome-unstable=54.0.2840.14-1
#       latest (equivalent to google-chrome-stable)
#       google-chrome-beta  (pull latest beta)
#============================================
ARG CHROME_VERSION="google-chrome-stable"
RUN 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-chrome.list \
  && apt-get update -qqy \
  && apt-get -qqy install \
    ${CHROME_VERSION:-google-chrome-stable} \
  && rm /etc/apt/sources.list.d/google-chrome.list \
  && rm -rf /var/lib/apt/lists/* /var/cache/apt/*

The Chrome installation steps were taken from here (as seen in the comments) and even using the version in the example I get the error

E: Version '53.0.2785.101-1' for 'google-chrome-stable' was not found

Tried other versions from https://chromereleases.googleblog.com/ and nothing works.

Do you know of a different way to install a specific version or if I'm doing something wrong with these steps?

like image 694
Joao Coelho Avatar asked Jul 01 '19 18:07

Joao Coelho


1 Answers

This took me a while to find, but you're installing from Google's repository and they only keep the latest versions of Google Chrome in their repositories. You could probably search for 3rd party repositories that have older versions of Chrome, but I personally wouldn't recommend that.

The current version is 75.0.3770.100-1 for google-chrome-stable at the time of this post. Will that not work for you?

Lastly, I directly copied your dockerfile and it worked for me with the latest build of google-chrome-stable installed on the image. How were you running docker?

Here was my process:

  1. Copied your docker file directly into ./Dockerfile
  2. docker build ./
  3. docker image ls
  4. Copied my image id (90206843f24e in my case)
  5. docker run --entrypoint "/bin/bash" -it 90206843f24e

You'll be dropped in a root shell on the docker image to "poke" around run google-chrome -version to verify the above version is installed

I hope this works for you. Good luck and keep us posted!

like image 134
Joshua Avatar answered Oct 02 '22 16:10

Joshua