docker - 如何在 openjdk :11 docker base image without "no installation candidate" error? 上安装 firefox

标签 docker dockerfile apt-get

我正在尝试使用 openjdk:11-slimopenjdk:11 作为我的基本图像来创建一个包含已安装 Firefox 浏览器的 docker 镜像。

这是我的 dockerfile 的最小可重现示例:

FROM openjdk:11

RUN rm -rf /var/lib/apt/lists/* && \
    apt-get update && apt-get install -y --no-install-recommends firefox

这是运行 docker build 的输出。:

$ docker build -t testing/simpleopenjdkfirefox .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM openjdk:11
 ---> 1eec9f9fe101
Step 2/2 : RUN rm -rf /var/lib/apt/lists/* &&     apt-get update && apt-get install -y --no-install-recommends firefox
 ---> Running in da4e93ffe4a1
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [121 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [268 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7860 B]
Fetched 8422 kB in 2s (4114 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Package firefox is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'firefox' has no installation candidate
The command '/bin/sh -c rm -rf /var/lib/apt/lists/* &&     apt-get update && apt-get install -y --no-install-recommends firefox' returned a non-zero code: 100

我认为应该可以运行 apt-get install firefox 的理由是:

我已尝试使用以下基本图像:

  • openjdk:11-slim - 我正在做的工作所需的基础镜像
  • openjdk:11 - 完整的 openjdk 镜像,应该是默认的工作案例
  • openjdk:11-buster - 看看 Debian 10 是否可以工作

为什么 apt-get 安装在 docker 构建中失败,但在 Ubuntu CLI 中却没有? 是 Linux 操作系统兼容性问题还是其他问题?

最佳答案

firefox 软件包仅在 Debian Unstable Repository(代号“Sid”)下可用。 Debian Stable 只有 firefox-esr。要在包索引更新中包含 Sid 存储库,您必须添加 deb http://deb.debian.org/debian/unstable main contrib non-free 作为 apt 的存储库源。

echo "deb http://deb.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list.d/debian.list
apt-get update
apt-get install -y --no-install-recommends firefox

如果 Sid 存储库没有最新版本的 Firefox,则检查的下一个最佳位置是 Mozilla 团队自己运营的 Firefox PPA(个人包存档)。 PPA 只是存储库,添加方式与上述 Sid 存储库完全相同:

例如,

sudo add-apt-repository ppa:mozillateam/firefox-next
sudo apt-get update

关于docker - 如何在 openjdk :11 docker base image without "no installation candidate" error? 上安装 firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65813715/

相关文章:

sql-server - 如何将Docker与Azure Data Studio连接?

将 Docker 容器代理为子域

使用 SHA 哈希的 Docker 图像搜索

ubuntu - apt-get install 是否取决于操作系统 (OS) 的内核版本或操作系统的分布?

networking - Spark SPARK_PUBLIC_DNS 和 SPARK_LOCAL_IP 在带有 docker 容器的独立集群上

docker - Docker-compose + Nginx + Certbot +简单的Django Rest Framework应用

docker - 如何将 google 实例设置保存为 docker 镜像?

bash - Docker 在 docker-compose up 上的主机中运行脚本

email - 在 ubuntu 上重新配置 bsd-mailx

ubuntu-14.04 - 出现错误 Ubuntu 14.04 Unmet dependency。尝试 'apt-get -f install' 不带包