英文:
"System.IO.IOException: Function not implemented" error while running dotnet docker compose project
问题
在Debian GNU/Linux 10 (buster)上运行的dotnet应用程序中,当在Program.cs文件中运行以下代码时:
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(options =>
{
// gRPC endpoint listening on port 5001.
// rest endpoint listening on port 80
});
webBuilder.UseStartup<Startup>();
});
它会产生以下错误:
Unhandled exception. System.IO.IOException: Function not implemented
at System.IO.FileSystemWatcher.StartRaisingEvents()
at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at tvod_core.Program.Main(String[] args) in /home/app-name/Program.cs:line 15
qemu: uncaught target signal 6 (Aborted) - core dumped
你正在Apple M1上运行此应用程序。以下是docker的版本信息:
docker -v
Docker version 23.0.5, build bc4487a
docker-compose -v
WARNING: Compose V1 is no longer supported and will be removed from Docker Desktop in an upcoming release. See https://docs.docker.com/go/compose-v1-eol/
docker-compose version 1.29.2, build 5becea4c
你尝试了禁用Docker中的文件系统事件监视,但没有成功:
webBuilder.ConfigureKestrel((context, options) =>
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var kestrelConfiguration = context.Configuration.GetSection("Kestrel");
options.AllowSynchronousIO = true;
options.Limits.MaxRequestBodySize = null;
}
});
问题可能与Linux系统上的FileSystemWatcher类有关,它可能具有有限的功能并且不支持Windows上可用的所有功能。你可以尝试以下方法来解决问题。
英文:
I have a dotnet app, which I am trying to run using Docker-Compose file. The container is running on "Debian GNU/Linux 10 (buster)".
In the Program.cs file, when I run the this code below,
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(options =>
{
// gRPC endpoint listening on port 5001.
// rest endpoint listening on port 80
});
webBuilder.UseStartup<Startup>();
});
it is giving following error.
Unhandled exception. System.IO.IOException: Function not implemented
at System.IO.FileSystemWatcher.StartRaisingEvents()
at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at tvod_core.Program.Main(String[] args) in /home/app-name/Program.cs:line 15
qemu: uncaught target signal 6 (Aborted) - core dumped
I am running this application on Apple M1. Below are docker versions,
>>> docker -v
Docker version 23.0.5, build bc4487a
>>> docker-compose -v
WARNING: Compose V1 is no longer supported and will be removed from Docker Desktop in an upcoming release. See https://docs.docker.com/go/compose-v1-eol/
docker-compose version 1.29.2, build 5becea4c
I tried:
I am new to dotnet, but I think issue seems to be with FileSystemWatcher class on Linux-based systems like Debian GNU/Linux which might have limited functionality and doesn't support all the features available on Windows. So, I tried Disabling file system event monitoring in Docker, but no luck.
webBuilder.ConfigureKestrel((context, options) =>
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var kestrelConfiguration = context.Configuration.GetSection("Kestrel");
options.AllowSynchronousIO = true;
options.Limits.MaxRequestBodySize = null;
}
});
答案1
得分: 1
重新加载配置在M1 Mac上的更改尚未实施。
相同的问题在此处被跟踪。 https://github.com/dotnet/aspnetcore/issues/38876
作为一种解决方法,我们必须添加此ENV标志以禁用FileSystemWatcher
ASPNETCORE_hostBuilder__reloadConfigOnChange=false
英文:
Reload configuration on changes has not been implemented on M1 Mac.
The same has been tracked here. https://github.com/dotnet/aspnetcore/issues/38876
As a workaround, we have to add this ENV flag to disable FileSystemWatcher
> ASPNETCORE_hostBuilder__reloadConfigOnChange=false
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论