在部署服务到docker的时候出现全球化错误

 

 

System . Global ization . Cul tureNotFoundException: Only the invariant culture is supported in globalizat ion- invariant mode. See https: //aka. ms/Globalizat i onInvari antMode for more information. (Parameter ” name' )
en-us is an invalid culture identifier.

en-us is an invalid culture

全球化不变模式可以在任何操作系统上启用,但您可能会在docker linux容器和IOT构建中找到它,其中存储和运行时内存大小受到限制。这个问题主要出现在Alpine linux容器上,其中通过删除ICU库并将运行时置于固定模式来使本机运行时大小尽可能小。这会导致生成映像变得小而快速,但会使您无法连接到 SQL Server。

可以选择在镜像中安装icu

在Dockerfile中写入以下命令

 

# Install cultures (same approach as Alpine SDK image)
RUN apk add --no-cache icu-libs

# Disable the invariant mode (set in base image)
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false

另一个解决方案就是不使用Alpine 的镜像