如何基于 Ubuntu 19.10 和 20.04 在 Docker 中安装 chromium?

How to install chromium in Docker based on Ubuntu 19.10 and 20.04?

我有这个简单的 docker 文件:

FROM ubuntu:eoan 

ENV DEBIAN_FRONTEND=noninteractive 

RUN apt update && apt install -y \ 
  chromium-browser \ 
  chromium-chromedriver

当我尝试构建它时:

...
Preparing to unpack .../00-chromium-browser_77.0.3865.120-0ubuntu1.19.10.1_amd64.deb ...
=> Installing the chromium snap
==> Checking connectivity with the snap store
===> Unable to contact the store, trying every minute for the next 30 minutes

而且它似乎永远不会到达所说的 snap 商店。 如果图像基于 disco 而不是 eoan,则效果很好。 在物理机上运行良好。

这不是解决方案,而是解决方法。只需使用 google-chrome 即可。 有一天,我突然遇到了这个问题,一直在构建的 docker 图像被破坏了。我的情况就像你的:ubuntu 19.10 作为 docker 图像的基础。

RUN curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get install -y ./google-chrome-stable_current_amd64.deb
RUN rm google-chrome-stable_current_amd64.deb