Unable to install Google Chrome on Docker

こ雲淡風輕ζ 提交于 2020-01-06 06:57:13

问题


I'm currently facing an issue in installing Google Chrome in my docker - this set up was working yesterday but as of today I'm getting this error -

This is how I'm installing Chrome

    ENV CHROME_VERSION "google-chrome-stable"
RUN apt-get update
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 -qqy install \
    ${CHROME_VERSION:-google-chrome-stable} \
  && rm /etc/apt/sources.list.d/google-chrome.list \
  && rm -rf /var/lib/apt/lists/*

This throws an error

W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages 404 Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.

If I remove the apt-get update part, then the above error doesn't come but the google-chrome-stable is not found

ENV 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 -qqy install \
        ${CHROME_VERSION:-google-chrome-stable} \
      && rm /etc/apt/sources.list.d/google-chrome.list \
      && rm -rf /var/lib/apt/lists/*

Then the error is

E: Unable to locate package google-chrome-stable

Further , I found a link which recommends removing jessie - https://lists.debian.org/debian-devel-announce/2019/03/msg00006.html

How can I configure to remove both the errors since this was working all fine yesterday and my docker build was successful.


回答1:


http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages delivers a 404 indeed. I don't know why that is but you are not the only person affected: https://github.com/docker-library/official-images/issues/3551

So as a workaround you have to comment out the line containing that URL in the sources.list before running apt-get update to make sure that it doesn't fail. I used sed for that (sed -i -- 's&deb http://deb.debian.org/debian jessie-updates main&#deb http://deb.debian.org/debian jessie-updates main&g').

So I could install chrome successfully by modifying your Dockerfile to look like:

FROM debian:jessie
ENV CHROME_VERSION "google-chrome-stable"
RUN sed -i -- 's&deb http://deb.debian.org/debian jessie-updates main&#deb http://deb.debian.org/debian jessie-updates main&g' /etc/apt/sources.list \
  && apt-get update && apt-get install wget -y
ENV 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 \
  && apt-get update && apt-get -qqy install ${CHROME_VERSION:-google-chrome-stable}
CMD /bin/bash


来源:https://stackoverflow.com/questions/55351622/unable-to-install-google-chrome-on-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!