在Docker容器中找不到'make'命令。

25

我有一个Docker镜像,在其中运行着Ubuntu14.04的Docker主机。

在其中一个容器中,我试图运行Zookeeper并安装librdkafka库(Kafka连接到第三方软件的先决条件库)。我需要使用“make”命令来构建我的librdkafka库,以便在容器内运行Kafka适配器/连接器。

然而,有趣的是我无法在容器内运行“make”命令,但在Docker主机上却可以正常工作。当我尝试使用

apt-get install make

我收到了以下信息,但它对我来说没有太多意义:

root@svi-esp-service:/# apt-get install make
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package make 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 'make' has no installation candidate

有人能帮我理解为什么该制品在容器中没有安装,为什么我无法运行它吗?我时间紧迫,需要在容器中运行这个命令...真的很烦人。

提醒一下,我在列表文件中有以下内容:

root@svi-esp-service:/# cat /etc/apt/sources.list
deb http://http.debian.net/debian jessie main
deb http://http.debian.net/debian jessie-updates main
deb http://security.debian.org jessie/updates main

非常感谢您的帮助!


你的容器有互联网访问权限吗?你能通过apt安装其他软件包吗? - Luciano Afranllie
2个回答

39

首先运行apt-get update来更新APT软件包列表:

apt-get update && apt-get install make

我之前尝试过,但是我得到了很多404错误:请在下面的pastebin中查找错误日志: https://pastebin.com/FM7NMiBx - Omkar
使用 --host=net 启动您的容器应该解决这个问题。 - loose11

12
RUN apt install build-essential -y --no-install-recommends

我推荐使用apt而不是apt-get, 这不仅会安装'make',还会安装其他可能需要的开发工具。同时可以加上-y和--no-install-recommends选项以避免阻塞构建过程 :)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接