"System.IO.IOException: Function not implemented" error while running dotnet docker compose project

huangapple go评论57阅读模式
英文:

"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) =&gt;
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =&gt;
        {
            webBuilder.ConfigureKestrel(options =&gt;
            {
                // gRPC endpoint listening on port 5001.
                // rest endpoint listening on port 80
            });

            webBuilder.UseStartup&lt;Startup&gt;();
        }); 

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.&lt;.ctor&gt;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,

&gt;&gt;&gt; docker -v
Docker version 23.0.5, build bc4487a
&gt;&gt;&gt; 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) =&gt;
            {
                if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    var kestrelConfiguration = context.Configuration.GetSection(&quot;Kestrel&quot;);
                    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

huangapple
  • 本文由 发表于 2023年7月17日 19:07:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76703843.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定