最小化泊坞窗与图片apt-get的建设DEPS [英] Minimizing Docker Images with apt-get build deps

查看:334
本文介绍了最小化泊坞窗与图片apt-get的建设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.

我在沿线的思维,如


  1. 有没有一种方法,以静态链接中的 泊坞窗-PHP-EXT安装 所以我可以攻击所有的 apt-get的东西?

  2. 如何消除由留下的数据apt-get的更新

  1. Is there a way to statically link the php libs in docker-php-ext-install so I can nuke all the apt-get stuff?
  2. 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中/公寓/列表/ * 例如:

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屋!

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