Docker中的Python映像大小很大 [英] Big size of python image in Docker

查看:1170
本文介绍了Docker中的Python映像大小很大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 Docker 测试我的应用。所以,我在 Dockerfile 中有这个:

I want to test my app with Docker. So, I have this in Dockerfile:

FROM python:3-onbuild
CMD [ "python", "./test.py" ]

test.py:

print(123)

然后我运行:

docker build -t my_test_app .

所以,我有一个大形象。 docker镜像返回:

So, I have one big image. docker images return:

REPOSITORY          TAG                 IMAGE ID        CREATED    VIRTUAL SIZE
python              3-onbuild           b258eb0a5195    8 days ago 757 MB

为什么文件这么大?

该文件大小正常吗?

推荐答案

我刚刚检查了在我的机器上,标准ubuntu:trusty映像为188 MB,包含所有python内容的映像为480MB。我经常看到800MB的映像,这些映像通常包含一些有意义的应用程序。

I just checked on my machine the standard ubuntu:trusty image is 188 MB and the image with all python stuff is 480MB. I see 800MB images quite often, those are usually ones that contain some meaningful application.

但是,这些映像是基于我们的私有映像的,因此官方Docker库映像似乎更大因为某些原因。他们意识到这一事实,并试图减少它。在此处

However, these images are based on our private images the official Docker library image seems much larger for some reason. They are aware of this fact and are trying to reduce it. Look at the discussion on the subject here

如果您需要较小的图像,请尝试使用此 rouge8 / pythons,它大约小100MB。

If you need a bit smaller image try this one 'rouge8/pythons' it is about 100MB smaller.

rouge8/pythons latest … 680.3 MB

请记住,docker映像按层次结构排列。因此,如果将相同的基础基本映像用于许多容器,则每个容器所添加的大小将非常小。只是基数加上您添加到特定容器中的任何内容之间的差。

Keep in mind, docker images are arranged as a hierarchical layer structure. So if you reuse the same underlying base image for many containers the size that each individual container adds is quite small. It will only be the difference between the base plus whatever you added into specific container.

这篇关于Docker中的Python映像大小很大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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