What is .build-deps for apk add --virtual command?

人盡茶涼 提交于 2019-12-29 11:31:02

问题


What is .build-deps in the following command? I can't find an explanation in the Alpine docs. Is this a file that is predefined? Is see this referenced in many Dockerfiles.

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

回答1:


If you see the documentation

  -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

What that means is when you install packages, those packages are not added to global packages. And this change can be easily reverted. So if I need gcc to compile a program, but once the program is compiled I no more need gcc.

I can install gcc, and other required packages in a virtual package and all of its dependencies and everything can be removed this virtual package name. Below is an example usage

apk add --virtual mypacks gcc vim
apk del mypacks

The next command will delete all 18 packages installed with the first command.



来源:https://stackoverflow.com/questions/46221063/what-is-build-deps-for-apk-add-virtual-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!