以下命令中的.build-deps
是什么?我在Alpine文档中找不到解释。这是预定义的文件吗?我看到很多Dockerfile中都有引用到它。
RUN apk add --no-cache --virtual .build-deps \
gcc \
freetype-dev \
musl-dev
RUN pip install --no-cache-dir <packages_that_require_gcc...> \
RUN apk del .build-deps
以下命令中的.build-deps
是什么?我在Alpine文档中找不到解释。这是预定义的文件吗?我看到很多Dockerfile中都有引用到它。
RUN apk add --no-cache --virtual .build-deps \
gcc \
freetype-dev \
musl-dev
RUN pip install --no-cache-dir <packages_that_require_gcc...> \
RUN apk del .build-deps
-t, --virtual NAME Instead of adding all the packages to 'world', create a new
virtual package with the listed dependencies and add that
to 'world'; the actions of the command are easily reverted
by deleting the virtual package
RUN apk add --virtual mypacks gcc vim \
&& apk del mypacks
.build-deps
是Alpine中称为“虚拟包”的任意名称,您可以在其中添加软件包。
它创建了一个额外的软件包集合,“有限的时间”内您需要这些软件包(例如编译器用于构建其他东西)。
其主要目的是尽可能使您的镜像保持精简和轻量化,因为一旦使用这些软件包后,您可以轻松地将其删除。
请记住,如果您想实现轻量级的主要目的,则应将其包含在相同的 RUN
中。