简体   繁体   English

在 Docker 容器中运行 do.net 6 应用程序时出现不变文化问题

[英]Invariant culture issue while running the dotnet 6 application in a Docker Container

I have upgraded do.net application from Do.net Core 3.1 to Do.net 6. After upgrading it I am getting this error:我已将 do.net 应用程序从 Do.net Core 3.1 升级到 Do.net 6。升级后出现此错误:

Microsoft.Azure.Storage.StorageException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en-US is an invalid culture identifier.
 ---> System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')

To fix this I found out that we can try setting the InvariantGlobalization as false in the csproj under and in the docker we can set ENV DO.NET_SYSTEM_GLOBALIZATION_INVARIANT=false .为了解决这个问题,我发现我们可以尝试在 csproj 中将InvariantGlobalization as false ,在 docker 中我们可以设置ENV DO.NET_SYSTEM_GLOBALIZATION_INVARIANT=false But when I make these change and rerun the application I am getting another error saying:但是当我进行这些更改并重新运行应用程序时,我收到另一个错误提示:

Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
   at System.Environment.FailFast(System.String)

And to fix for this suggestions are just vice versa of what I have done to fix the invariant culture(1st issue).修复这些建议与我修复不变文化(第一期)所做的相反。 Could some one please help me out with this.有人可以帮我解决这个问题吗?

My docker file looks like:我的 docker 文件如下所示:

FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine3.14
LABEL pipelineName="somedummyapplication" \
      pipelineKey="DSENJRNF" \
      offeringKey="UQWHCLRA"
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
RUN echo 'http://dl-3.alpinelinux.org/alpine/v3.16/main' >> /etc/apk/repositories 
RUN apk upgrade && apk add sqlite && apk add krb5
EXPOSE 5000
ENV ASPNETCORE_URLS=http://*:5000
WORKDIR /app
COPY . /app
USER guest
ENTRYPOINT ["dotnet", "abc.somedummyapplication.dll"]

I have already checked and tries these links to fix the issue but as I said if I resolve on another issue comes up: Running .NET 6 project in Docker throws Globalization.CultureNotFoundException and Process terminated.我已经检查并尝试使用这些链接来解决问题,但正如我所说,如果我解决了另一个问题: Running .NET 6 project in Docker throws Globalization.CultureNotFoundException and Process terminated。 Couldn't find a valid ICU package installed on the system in Asp.Net Core 3 - ubuntu 在 Asp.Net Core 3 的系统上找不到有效的 ICU package - ubuntu

Alpine-based images do not contain ICU, you need to install it manually:基于Alpine的镜像不包含ICU,需要手动安装:

apk add icu-data-full icu-libs

You might also bump into a similar issue with TimeZoneInfo.FindSystemTimeZoneById , because Alpine-based images do not include tzdb:您可能还会遇到与TimeZoneInfo.FindSystemTimeZoneById类似的问题,因为基于 Alpine 的图像不包括 tzdb:

apk add tzdata

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM