无法在以 ubuntu 作为基本映像的 dockerfile 中安装 hadoop

问题描述

当我运行下面的代码时,我得到这个错误,E: Unable to locate package hadoop

FROM ubuntu:20.04
RUN apt-get update -y \
 && apt-get install -y apt-utils \
 && apt-get install python3.8 -y
RUN apt-get install jupyter -y
RUN apt-get install hadoop -y
RUN rm -rf /var/lib/apt/lists/*
ADD sample.py /
LABEL maintainer=Ammar
CMD [ "python","./sample.py" ]

解决方法

此链接:https://computingforgeeks.com/install-apache-hadoop-hbase-on-ubuntu-linux/ 包含 Hadoop 安装的完整示例。我认为同样应该在 Docker 中一步一步完成。

apt-get install hadoop 在不添加外部存储库的情况下无法在 ubuntu 中工作。但是如果你知道外部 repo,那么你必须添加 softwaree-properties-common 包(像这样:https://stackoverflow.com/a/52091668/1852444) 然后通过 apt-add-repository 命令添加您的存储库。

,

某些“foss”软件和不属于 foss 的软件未添加到 ubuntu 存储库中,因此无法使用 apt 进行安装,因为 apt 使用这些存储库来安装软件包。

hadoop 是未添加到 ubuntu 存储库的这些软件包之一。有关存储库的更多信息,您可以查看 here

您可以拉取和使用其他人在 dockerhub 中创建和推送的 hadoop 容器映像之一,而不是从头开始创建它。

如果您仍想创建自己的 hadoop 容器映像,您可以查看 this 示例 hadoop dockerfile