Docker 镜像过度增长
我有 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Alpine Linux 是一个围绕
musl、libc
和 BusyBox 构建的 Linux 发行版。该镜像大小仅为 5 MB,并且可以访问比其他基于 BusyBox 的镜像更完整的包存储库。来自高山:最新# 5 MB
RUN apk add python3 # 添加另一层python3 I:e 40+MB
对于 CentOS,您需要运行 yum clean all 和 所以回答
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
For CentOS you need to run yum clean all and SO Answer