如何构建Ubuntu容器并安装多个程序

时间:2018-11-28 20:00:12

标签: docker ubuntu

我环顾四周,似乎以前没有问过这个问题,但是我可能错过了它。

我正在尝试构建一个超级基本的ubuntu容器,并在其上安装一些不同的东西。

过去,我用该行构建了一个python容器

RUN pip install --trusted-host pypi.python.org -r program/requirements.txt

所以我需要的每个python依赖项都在requirements.txt

我想要的是一种为Ubuntu容器创建requirements.txt的方式,其中可能包含

vim
apache2-utils
etc

然后在我的Dockerfile中说

RUN apt-get update
RUN apt-get install program/requirements.txt

有没有办法做到这一点?还是我只需要在Dockerfile中包含所有要求?

2 个答案:

答案 0 :(得分:1)

我编写的每个Dockerfile都明确列出了它们

// Show the alert
$('.alert').removeClass('d-none').addClass('show');

// Hide the alert
$('.alert').addClass('d-none').removeClass('show');

还请注意,对于多阶段Dockerfile,拥有两个需要的单独软件包列表非常合理,一个用于构建应用程序,另一个用于运行它。

答案 1 :(得分:0)

sed 's/#.*//' program/requirements.txt | xargs apt-get install

您甚至可以通过此sed技巧在requirements.txt中添加评论