【问题标题】:Unable to install Google Chrome on Docker无法在 Docker 上安装 Google Chrome
【发布时间】:2019-03-26 07:15:44
【问题描述】:

我目前在我的 docker 中安装 Google Chrome 时遇到了一个问题 - 这个设置昨天还在工作,但到今天我收到了这个错误 -

这就是我安装 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/*

这会引发错误

W:无法获取http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages 404 Not Found

E: 某些索引文件下载失败。它们已被忽略,或使用旧的。

如果我删除 apt-get update 部分,则不会出现上述错误,但找不到 google-chrome-stable

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/*

那么错误就是

E: 找不到包 google-chrome-stable

此外,我发现了一个链接,建议删除 jessie - https://lists.debian.org/debian-devel-announce/2019/03/msg00006.html

我该如何配置以消除这两个错误,因为昨天一切正常,并且我的 docker 构建成功。

【问题讨论】:

    标签: google-chrome docker dockerfile debian-jessie


    【解决方案1】:

    http://deb.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages 确实提供了 404。我不知道为什么会这样,但你不是唯一受影响的人:https://github.com/docker-library/official-images/issues/3551

    因此,作为一种解决方法,您必须在运行apt-get update 之前注释掉sources.list 中包含该URL 的行,以确保它不会失败。我为此使用了sed (sed -i -- 's&deb http://deb.debian.org/debian jessie-updates main&#deb http://deb.debian.org/debian jessie-updates main&g')。

    所以我可以通过修改你的 Dockerfile 来成功安装 chrome:

    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
    

    【讨论】:

    • 我在本地 docker 中尝试过这个,但它卡在了 Reading package lists...
    • 我可以确认Reading package lists... 需要很长时间(并且显示两次),但它会在大约 20 秒后继续移动。请在您的docker build 命令中使用 --no-cache 重试 .. 并给它一些时间。在两台不同的机器上试过。
    • 嗯。我等了超过一分钟,它还没有动。使用--no-cache 运行没有什么不同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-03
    • 2016-12-08
    • 1970-01-01
    相关资源
    最近更新 更多