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

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

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

问题

在Debian GNU/Linux 10 (buster)上运行的dotnet应用程序中,当在Program.cs文件中运行以下代码时:

  1. public static void Main(string[] args)
  2. {
  3. CreateHostBuilder(args).Build().Run();
  4. }
  5. public static IHostBuilder CreateHostBuilder(string[] args) =>
  6. Host.CreateDefaultBuilder(args)
  7. .ConfigureWebHostDefaults(webBuilder =>
  8. {
  9. webBuilder.ConfigureKestrel(options =>
  10. {
  11. // gRPC endpoint listening on port 5001.
  12. // rest endpoint listening on port 80
  13. });
  14. webBuilder.UseStartup<Startup>();
  15. });

它会产生以下错误:

  1. Unhandled exception. System.IO.IOException: Function not implemented
  2. at System.IO.FileSystemWatcher.StartRaisingEvents()
  3. at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
  4. at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
  5. at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
  6. at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
  7. at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
  8. at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
  9. at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
  10. at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
  11. at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
  12. at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
  13. at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
  14. at Microsoft.Extensions.Hosting.HostBuilder.Build()
  15. at tvod_core.Program.Main(String[] args) in /home/app-name/Program.cs:line 15
  16. qemu: uncaught target signal 6 (Aborted) - core dumped

你正在Apple M1上运行此应用程序。以下是docker的版本信息:

  1. docker -v
  2. Docker version 23.0.5, build bc4487a
  3. docker-compose -v
  4. 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/
  5. docker-compose version 1.29.2, build 5becea4c

你尝试了禁用Docker中的文件系统事件监视,但没有成功:

  1. webBuilder.ConfigureKestrel((context, options) =>
  2. {
  3. if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
  4. {
  5. var kestrelConfiguration = context.Configuration.GetSection("Kestrel");
  6. options.AllowSynchronousIO = true;
  7. options.Limits.MaxRequestBodySize = null;
  8. }
  9. });

问题可能与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,

  1. public static void Main(string[] args)
  2. {
  3. CreateHostBuilder(args).Build().Run();
  4. }
  5. public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
  6. Host.CreateDefaultBuilder(args)
  7. .ConfigureWebHostDefaults(webBuilder =&gt;
  8. {
  9. webBuilder.ConfigureKestrel(options =&gt;
  10. {
  11. // gRPC endpoint listening on port 5001.
  12. // rest endpoint listening on port 80
  13. });
  14. webBuilder.UseStartup&lt;Startup&gt;();
  15. });

it is giving following error.

  1. Unhandled exception. System.IO.IOException: Function not implemented
  2. at System.IO.FileSystemWatcher.StartRaisingEvents()
  3. at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
  4. at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
  5. at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
  6. at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
  7. at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
  8. at Microsoft.Extensions.Configuration.FileConfigurationProvider.&lt;.ctor&gt;b__1_0()
  9. at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
  10. at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
  11. at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
  12. at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
  13. at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
  14. at Microsoft.Extensions.Hosting.HostBuilder.Build()
  15. at tvod_core.Program.Main(String[] args) in /home/app-name/Program.cs:line 15
  16. qemu: uncaught target signal 6 (Aborted) - core dumped

I am running this application on Apple M1. Below are docker versions,

  1. &gt;&gt;&gt; docker -v
  2. Docker version 23.0.5, build bc4487a
  3. &gt;&gt;&gt; docker-compose -v
  4. 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/
  5. 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.

  1. webBuilder.ConfigureKestrel((context, options) =&gt;
  2. {
  3. if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
  4. {
  5. var kestrelConfiguration = context.Configuration.GetSection(&quot;Kestrel&quot;);
  6. options.AllowSynchronousIO = true;
  7. options.Limits.MaxRequestBodySize = null;
  8. }
  9. });

答案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:

确定