Docker中限制42层的原因是什么? [英] What's the reason for the 42 layer limit in Docker?

查看:274
本文介绍了Docker中限制42层的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在不同的地方,我发现了一个信息,即泊坞窗映像最多只能包含42层。

At different places I found the information that a docker image can only consist of up to 42 layers. This seems to be a limitation of the used AUFS file system.

有人可以告诉我为什么存在这个限制吗?或者有人有一些文档对此进行解释吗?

Can anybody tell me why this limit exists or does anybody have some documentation explaining this?

推荐答案

我开始怀疑没有这么硬的限制。

I'm starting to suspect that there isn't any such a hard limit.

创建以下python脚本,并将其命名为 makeDockerfile.py

Create the following python script, and name it "makeDockerfile.py"

with open("Dockerfile", "w") as file:
    file.write("from alpine:3.8\n")
    for i in range(0, 201):
        file.write("run echo {i}\n".format(i=i))

然后运行
python makeDockerfile.py &&码头工人建造--tag manylayer。 && docker run -it manylayer / bin / sh
您会看到您正在运行> 200层。

then run python makeDockerfile.py && docker build --tag manylayer . && docker run -it manylayer /bin/sh You'll see that you are running a working container with > 200 layers.

(请注意,这已经在linux上的linux容器中进行了测试)

(note, this was tested with linux containers on linux)

请注意,这并不意味着必须有这么多的层支持,只是它们在某些情况下是可能的。

Note that this doesn't mean that this many layers are necessarily SUPPORTED, just that they are possible in some cases.

实际上,我已经看到容器失败的原因远远少于42层,并且删除任何任意层似乎都可以解决该问题。 (请参见 https://github.com/docker/for-win/ issue / 676#issuecomment-462991673

In fact, I've seen containers fail with far fewer than 42 layers, and removing any arbitrary layer seems to fix it. (see https://github.com/docker/for-win/issues/676#issuecomment-462991673 )

编辑

thaJeztah ,Docker的维护者,对此有这样的看法:

thaJeztah, maintainer of Docker, has this to say about it:


42层限制在aufs上使用的是较早版本的aufs,但现在不再如此。

The "42 layer limit" on aufs was on older versions of aufs, but should no longer be the case.

但是,127层的限制仍然存在。这是由于Linux的限制,即对使用的syscall不接受超过X个参数。

However, the 127 layer limit is still there. This is due to a restriction of Linux not accepting more than X arguments to a syscall that's used.

尽管在现代内核中可以提高此限制,但这不是默认值,所以如果d超过该最大值,在一台计算机上构建的映像可能无法在另一台计算机上使用。

Although this limit can be raised in modern kernels, it's not the default, so if we'd go beyond that maximum, an Image built on one machine may not be usable on another machine.

(请参阅 https://github.com/docker/docker.github.io/issues/8230

这篇关于Docker中限制42层的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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