最小化泊坞窗与图片apt-get的建设DEPS [英] Minimizing Docker Images with apt-get build deps
问题描述
有时候构建泊坞窗图像时,有必要使用 apt-get的
。例如,对于运行Magento的图像可能会开始像这样
Sometimes when building Docker images it's necessary to use apt-get
. For example, an image for running Magento might start something like this
FROM php:5.4-apache
RUN apt-get -qqy update \
&& apt-get -qqy install git \
libmcrypt-dev \
libpng12-dev \
libxml2-dev \
libxslt-dev \
&& docker-php-ext-install bcmath \
gd \
mcrypt \
mysql \
soap \
xsl \
zip
但现在我有那些 apt-get的
命令带来了所有的垃圾。更糟的是,我甚至不知道我能买得起删除,因为presumably的PHP库是动态链接的。
But now I have all the junk brought in by those apt-get
commands. Worse, I'm not even sure what I can afford to delete, because presumably the php libs are dynamically linked.
我在沿线的思维,如
- 有没有一种方法,以静态链接中的
泊坞窗-PHP-EXT安装
所以我可以攻击所有的apt-get的
东西? - 如何消除由
留下的数据apt-get的更新
?
- Is there a way to statically link the php libs in
docker-php-ext-install
so I can nuke all theapt-get
stuff? - How can I remove the data left by
apt-get update
?
但这些都是真的只是 X-Y问题。我的实际问题就是
but those are really just X-Y questions. My actual question is just
的如何建立更小的泊坞窗图像,而不完全是交易走了易于使用的Dockerfile使用 apt-get的
和可维护性?
How can I build smaller Docker images without entirely trading away the ease-of-use and maintainability of using apt-get
in the Dockerfile?
推荐答案
您可以得到由运行室射频的/ var / lib中/公寓/列表/ * $摆脱一些东西,一些东西C $ C>例如:
You can get rid of some stuff some stuff by running rm -rf /var/lib/apt/lists/*
e.g.
RUN apt-get update \
&& apt-get install -y MY_PACKAGE \
&& rm -rf /var/lib/apt/lists/*
请记住,你需要在同一行运行这个apt-get的更新
它是有效的。
这篇关于最小化泊坞窗与图片apt-get的建设DEPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!