Python基础映像与Ubuntu基础映像分别在docker

时间:2017-11-01 02:52:47

标签: python ubuntu docker

我刚开始使用docker将其应用到我的应用程序中。 我在做的时候,我有疑问。 请理解这可能是一个微不足道的问题。 我是码头工的新手。

直观地使用OS(ubuntu)图像作为基础似乎比纯python相对更重。

这就是为什么我总是尝试仅使用python图像作为基础,即使有一些ubuntu用例。

但是,我发现即使我使用python图像作为容器的基础它仍然可以运行Linux(Ubuntu)命令,如apt-getls,{{1并且具有类似psubuntu)的文件系统结构。

它看起来仍然很像home, root , usr

我知道如果我只使用ubuntu图像,我应该手动设置环境,与ubuntu图像形成对比。(如果我想要的只是运行python)

除方便方面外,他们是否有任何不同之处,说明我应该使用python以外的python,例如稳定性和性能?

2 个答案:

答案 0 :(得分:3)

您可以在documentation

中了解python图片

有趣的部分是:

  

此标记基于buildpack-deps。 buildpack-deps是为在其系统上有许多图像的docker的普通用户设计的。它在设计上有大量非常常见的Debian软件包。

buildpack-deps本身可以基于Debian或Ubuntu图像。

正如他们在文档中提到的那样 - 如果您没有具体要求,或者不知道为什么您不使用其他图像,那么python是一个不错的选择。

将来,如果您希望部署映像小于测试部署映像(可能有一些额外的工具),您可能会对其他映像感兴趣。或者通常,您可能会尝试使用可能的最小尺寸来删除不必要的实用程序。有充分的理由去做这些事情 - 你可能会在这些问题上找到自己。

答案 1 :(得分:2)

好吧,正如viraptor所说,Python是一个不错的选择,但重量只有900 MB

Python图像的大小 - 为什么是900MB?

https://github.com/docker-library/python/issues/30

有一篇关于docker图像大小的博客文章(事实上只有Python码头图片)由Yasser Martinez撰写

http://yasermartinez.com/blog/posts/creating-super-small-docker-images.html

提取

Python itself is not small, a typical python installation needs close to 100 MB once uncompressed on the disk. Of course one could imagine that here are many files included that aren't needed in most of the usual cases (like the turtle module). Is it possible to create a smaller python docker image? The answer is YES; if you now do a docker pull elyase/staticpython you will get a working python image with only 8.5 MB in size.

另见JoãoFerreiraLoff的github

https://github.com/jfloff/alpine-python

提取

REPOSITORY TAG SIZE jfloff/alpine-python 2.7-slim 52.86 MB python 2.7-slim 180.8 MB

jfloff/alpine-python 2.7 234.2 MB python 2.7 676.2 MB

jfloff/alpine-python 3.4-slim 110.4 MB python 3.4-slim 193.9 MB

jfloff/alpine-python 3.4 280 MB python 3.4 681.5 MB

jfloff/alpine-python latest 248.8 MB python 3.5 685.4 MB

jfloff/alpine-python latest-slim 79.11 MB python 3.5-slim 197.8 MB