M1芯片Mac使用docker-compose启动EventStore容器后立刻退出问题问询
M1芯片Mac运行Docker版EventStore启动失败解决方案
问题根因
该报错是M1系列ARM架构设备通过Docker运行x86架构EventStore镜像的典型兼容问题:Docker的Rosetta 2转译层未完整兼容.NET运行时的FileSystemWatcher接口,导致服务启动时调用文件监听相关API直接抛出Function not implemented异常终止运行。
原始报错日志
执行任务: docker logs --tail 1000 -f efb9a01f49d5383851f28e9badbd0934b1bc8a7b7cf1db018ed3a7b0436df25d <
[1, 1,14:24:17.218,FTL] Host terminated unexpectedly. 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.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state) 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 EventStore.Common.Log.EventStoreLoggerConfiguration.Initialize(String logsDirectory, String componentName, String logConfig) in /build/src/EventStore.Common/Log/EventStoreLoggerConfiguration.cs:line 58 at EventStore.Core.EventStoreHostedService`1.Init(TOptions options) in /build/src/EventStore.Core/EventStoreHostedService.cs:line 89 at EventStore.ClusterNode.ClusterVNodeHostedService.Init(ClusterNodeOptions options) in /build/src/EventStore.ClusterNode/ClusterVNodeHostedService.cs:line 44 at EventStore.Core.EventStoreHostedService`1..ctor(String[] args) in /build/src/EventStore.Core/EventStoreHostedService.cs:line 45 at EventStore.ClusterNode.ClusterVNodeHostedService..ctor(String[] args) in /build/src/EventStore.ClusterNode/ClusterVNodeHostedService.cs:line 35 at EventStore.ClusterNode.Program.Main(String[] args) in /build/src/EventStore.ClusterNode/Program.cs:line 22
终端将被任务复用,按任意键关闭。
可执行解决方案
- 方案1:使用原生ARM64架构镜像
EventStore 21.10及以上版本已正式提供arm64架构镜像,直接在docker-compose配置中指定对应arm64标签的镜像即可,示例配置:
无需额外修改其他配置,原生架构运行不存在转译兼容问题。image: eventstore/eventstore:23.10.0-arm64v8 - 方案2:禁用配置文件监听(适用于必须使用旧版本x86镜像的场景)
在docker-compose的EventStore服务的environment配置段添加如下环境变量,绕过FileSystemWatcher调用:
该参数会关闭服务对配置文件变更的自动监听,修改配置后需要手动重启服务生效。environment: - EVENTSTORE_CONFIG__DISABLEFILEWATCHERS=true - 方案3:修复挂载卷兼容问题
如果你配置了本地目录挂载到EventStore容器内,可先将挂载方式替换为Docker托管卷,避免macOS本地文件系统与Docker转译层的兼容冲突,示例配置:
同时建议升级Docker Desktop到最新正式版,已修复大量arm64架构下的文件系统兼容bug。services: eventstore: # 其他配置省略 volumes: - eventstore-data:/var/lib/eventstore volumes: eventstore-data:
内容的提问来源于stack exchange,提问作者Raghad Alafeef
相关产品推荐
相关产品推荐

