gpt4 book ai didi

image - centos docker 镜像太大

转载 作者:行者123 更新时间:2023-12-04 19:42:50 24 4
gpt4 key购买 nike

我用这个 Dockerfile 构建了一个图像。

FROM sanmingzi/ruby:1.9.3

RUN yum -y install gcc ruby-devel zlib-devel \
&& yum -y remove gcc ruby-devel zlib-devel \
&& yum -y clean all \
&& rm -rf /var/cache/yum \
&& rm -rf /var/tmp/*

我希望新图像的大小与 sanmingzi/ruby:1.9.3 相同,但我错了。比旧图像大约有 50MB。我用 docker history显示细节。
IMAGE               CREATED             CREATED BY                                      SIZE
b154156f1053 4 minutes ago /bin/sh -c yum -y install gcc ruby-devel z... 55.4MB

最佳答案

当我们安装gcc , ruby-develzlib-devel在 CentOS 镜像中,还安装或升级了许多其他依赖包:

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
gcc x86_64 4.8.5-16.el7_4.2 updates 16 M
ruby-devel x86_64 2.0.0.648-33.el7_4 updates 131 k
Installing for dependencies:
cpp x86_64 4.8.5-16.el7_4.2 updates 6.0 M
glibc-devel x86_64 2.17-196.el7_4.2 updates 1.1 M
glibc-headers x86_64 2.17-196.el7_4.2 updates 676 k
kernel-headers x86_64 3.10.0-693.21.1.el7 updates 6.0 M
libgomp x86_64 4.8.5-16.el7_4.2 updates 154 k
libmpc x86_64 1.0.1-3.el7 base 51 k
mpfr x86_64 3.1.1-4.el7 base 203 k
ruby x86_64 2.0.0.648-33.el7_4 updates 71 k
ruby-irb noarch 2.0.0.648-33.el7_4 updates 92 k
ruby-libs x86_64 2.0.0.648-33.el7_4 updates 2.8 M
rubygem-bigdecimal x86_64 1.2.0-33.el7_4 updates 83 k
rubygem-io-console x86_64 0.4.2-33.el7_4 updates 54 k
rubygem-json x86_64 1.7.7-33.el7_4 updates 79 k
rubygem-psych x86_64 2.0.0-33.el7_4 updates 82 k
rubygem-rdoc noarch 4.0.0-33.el7_4 updates 322 k
rubygems noarch 2.0.14.1-33.el7_4 updates 219 k
Updating for dependencies:
libgcc x86_64 4.8.5-16.el7_4.2 updates 98 k

Transaction Summary
================================================================================
Install 2 Packages (+16 Dependent packages)
Upgrade ( 1 Dependent package)

然后我们只删除 gcc , ruby-develzlib-devel :
Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
gcc x86_64 4.8.5-16.el7_4.2 @updates 37 M
ruby-devel x86_64 2.0.0.648-33.el7_4 @updates 337 k
zlib-devel x86_64 1.2.7-17.el7 @base 132 k
Removing for dependencies:
openssl-devel x86_64 1:1.0.2k-8.el7 @base 3.1 M

Transaction Summary
================================================================================
Remove 3 Packages (+1 Dependent package)

这就是为什么我们的最终图像比原始图像具有更大的尺寸。

关于image - centos docker 镜像太大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49447442/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com