更改Docker容器中的inotify.max_user_instances限制 [英] Change inotify.max_user_instances limit in Docker container

查看:106
本文介绍了更改Docker容器中的inotify.max_user_instances限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Dockerfile级别上更改docker env的inotify.max_user_instances设置.我正在尝试这样做,因为我收到此错误:

I am trying to change inotify.max_user_instances setting for docker env on the level of Dockerfile. I am trying to do it because I am receiving this error:

应用程序启动异常:System.IO.IOException:已配置的用户已达到inotify实例数量的上限(128).

Application startup exception: System.IO.IOException: The configured user limit (128) on the number of inotify instances has been reached.

我已经使用:

 .AddJsonFile($"appsettings.json", optional: true, reloadOnChange: false);

我也尝试使用自定义"WebHost.CreateDefaultBuilder(args)",因为有人指出它对同一文件使用reloadOnChange:true.

I as well tried to use custom "WebHost.CreateDefaultBuilder(args)", because it was pointed out that it uses reloadOnChange: true with the same file.

也尝试在dockerfile中运行:

Tried as well running in dockerfile:

RUN sysctl -w fs.inotify.max_user_watches=1048576
RUN echo fs.inotify.max_user_watches=1048576 | tee -a /etc/sysctl.conf && sysctl -p

但是有人指出,不可能从这种情况下运行.

But it was pointed out that it is impossible to run from that context.

是否有可能从docker映像构建/部署阶段更改这些sysctl设置?我对此有些迷茫.

Is there possibility to change those sysctl settings from the stage of docker image build/deployment? I am a little lost in this.

如果有帮助,则应用程序正在使用.net core 2.2

If it helps, application is using .net core 2.2

推荐答案

是否有可能从docker映像构建阶段更改这些sysctl设置

Is there possibility to change those sysctl settings from the stage of docker image build

不.映像构建的输出只是一个文件系统映像,外加一些有关默认环境变量和在 docker run 映像时要运行的命令的元数据.它不包括正在运行的进程,sysctl值或其他任何东西.

No. The output of the image build is only a filesystem image, plus some metadata about the default environment variables and command to run when you docker run the image. It does not include running processes, sysctl values, or anything else.

请记住,sysctl设置通常是全局内核级别的设置.由于所有Docker容器共享主机的内核,因此它们通常共享相同的sysctl值.(由于容器通常也具有隔离的文件系统,因此通过inotify监视文件系统的更改并不是真正的常见用例;如果代码或其他图像上下文发生了重大变化,则重建图像然后删除并重新创建图像更为常见.容器.)

Remember that sysctl settings are usually global kernel-level settings; since all Docker containers share the host's kernel, they usually share the same sysctl values. (Since containers also generally have isolated filesystems, watching for filesystem changes via inotify isn't really a common use case; if there's a substantial change in the code or other image context, it's more common to rebuild the image and then delete and recreate the container.)

您可以通过 docker运行--sysctl ,但是这些不包括inotify值.更改此值的唯一方法是在Docker外部的主机上以root用户身份运行 sysctl .

这篇关于更改Docker容器中的inotify.max_user_instances限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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