Docker 镜像过度增长

发布于 2025-01-15 01:19:13 字数 633 浏览 4 评论 0原文

我有 3 个简单的 docker 文件。 上安装 python3

在每个文件中,我在基本映像 centos:7、oraclelinux:7-slim 和 alpine:latest

。 python3安装过程表明安装的文件(python3和依赖项)约为50MB。但是当我构建新镜像时,centos 镜像从 204MB 增长到 413MB,oraclelinux 镜像从 132MB 增长到 480MB,alpine 从 5.59MB 增长到 54MB。 因此,只有新的 alpine 图像才有意义,因为它增长了近 50MB。 但为什么新的 centos 和 oraclelinux 镜像比应有的大呢?

Centos 的 Dockerfile:

FROM centos:7
RUN yum install -y python3

oraclelinux 的 Dockerfile:

FROM oraclelinux:7-slim
RUN yum install -y python3

alpine 的 Dockerfile:

FROM alpine:latest
RUN apk add python3

I have 3 simple docker files. In every file I install python3 on the

base image centos:7, oraclelinux:7-slim and alpine:latest.

The python3 installation process indicates the installed files (python3 and dependencies) are about 50MB. But when I build the new images, the centos image grows from 204MB to 413MB, the oraclelinux image grows from 132MB to 480MB and alpine grows from 5.59MB to 54MB.
So, only new alpine image make sense as it grows almost 50MB.
But why are new centos and oraclelinux images so larger than they should be?

Dockerfile for centos:

FROM centos:7
RUN yum install -y python3

Dockerfile for oraclelinux:

FROM oraclelinux:7-slim
RUN yum install -y python3

Dockerfile for alpine:

FROM alpine:latest
RUN apk add python3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

作业与我同在 2025-01-22 01:19:13

使用的 Alpine 图像尺寸较小。

  • Alpine Linux 是一个围绕 musl、libc 和 BusyBox 构建的 Linux 发行版。该镜像大小仅为 5 MB,并且可以访问比其他基于 BusyBox 的镜像更完整的包存储库。

    来自高山:最新# 5 MB
    RUN apk add python3 # 添加另一层python3 I:e 40+MB

为什么新的 centos 镜像这么大?

对于 CentOS,您需要运行 yum clean all所以回答

Alpine Image used be have less size.

  • an Alpine Linux is a Linux distribution built around musl, libc and BusyBox. The image is only 5 MB in size and has access to a package repository that is much more complete than other BusyBox based images.

    FROM alpine:latest # 5 MB
    RUN apk add python3 # adding another layer of python3 I:e 40+MB

Why are new centos images so larger?

For CentOS you need to run yum clean all and SO Answer

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文