簡體   English   中英

在 Docker 容器中運行 do.net 6 應用程序時出現不變文化問題

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

我已將 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')

為了解決這個問題,我發現我們可以嘗試在 csproj 中將InvariantGlobalization as false ,在 docker 中我們可以設置ENV DO.NET_SYSTEM_GLOBALIZATION_INVARIANT=false 但是當我進行這些更改並重新運行應用程序時,我收到另一個錯誤提示:

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)

修復這些建議與我修復不變文化(第一期)所做的相反。 有人可以幫我解決這個問題嗎?

我的 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"]

我已經檢查並嘗試使用這些鏈接來解決問題,但正如我所說,如果我解決了另一個問題: Running .NET 6 project in Docker throws Globalization.CultureNotFoundException and Process terminated。 在 Asp.Net Core 3 的系統上找不到有效的 ICU package - ubuntu

基於Alpine的鏡像不包含ICU,需要手動安裝:

apk add icu-data-full icu-libs

您可能還會遇到與TimeZoneInfo.FindSystemTimeZoneById類似的問題,因為基於 Alpine 的圖像不包括 tzdb:

apk add tzdata

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM