高山`apk`是否有ubuntu`apt` --no-install-recommends`等效项 [英] Does alpine `apk` have an ubuntu `apt` `--no-install-recommends` equivalent

查看:578
本文介绍了高山`apk`是否有ubuntu`apt` --no-install-recommends`等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作我能摆脱的绝对最小的Docker映像,因此我已经从以ubuntu为基础的位置切换到了alpine.

I'm trying to make the absolute smallest Docker image I can get away with, so I have switched from ubuntu as my base to alpine.

对于apt,我曾经使用--no-install-recommends来最小化与所需软件包一起安装的依赖关系".我是否需要将apk传递给它一个等效的标志,或者这是此瘦身操作系统的默认行为?

For apt, I used to use --no-install-recommends to minimize "dependencies" installed with my desired packages. Is there an equivalent flag I need to pass along with apk or is this the default behavior for this slimmed down OS?

推荐答案

不,我认为它没有相同的标志,因为它甚至没有下载推荐软件包的相同行为.

No it doesn't have the same flag I think because it does not even do the same behaviour of downloading recommended packages.

但是还有另一个标志--virtual可以帮助缩小图像:

However there is another flag --virtual which helps keep your images smaller:

apk add --virtual somename package1 package2

然后

apk del somename 

这对于仅需要构建但以后不需要执行的东西很有用.

This is useful for stuff needed for only build but not for execution later.

请注意,您必须在一个RUN命令中执行它,否则无法将它从上一个Docker映像层中删除.

Note you must execute it in one RUN command, else it cannot be deleted from the previous Docker image layer.

例如如果pything1需要运行package1package2,但在安装构建过程中仅需要package3package4,则将是最佳选择:

e.g. if pything1 needs package1 and package2 to run, but only needs package3 and package4 during the install build, this would be optimal:

RUN apk add --no-cache package1 package2
RUN apk add --no-cache --virtual builddeps package3 package4 && \
    pip install pything1 && \
    apk del builddeps 

程序包3和4并未添加世界"程序包,但在写入层之前已被删除.

package 3 and 4 are not added the "world" packages but are removed before the layer is written.

这个问题反过来又问了这个问题:什么是.build-deps for apk add --virtual命令?

This question asks the question other way round: What is .build-deps for apk add --virtual command?

这篇关于高山`apk`是否有ubuntu`apt` --no-install-recommends`等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆