我正在尝试从Windows容器运行传统的ASP.Net(.Net 4.7.1)应用程序。其中一个要求是将系统区域性,区域设置和位置设置为en-GB。如果绝对需要,我不允许触摸代码,只允许触摸web.config。
考虑以下方法:
我的基本图像的Dockerfile是:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2
ARG site_root=.
WORKDIR /scripts
COPY scripts/ .
RUN powershell -f install-certificates.ps1
RUN powershell C:/Windows/System32/inetsrv/appcmd.exe set config /commit:WEBROOT /section:globalization /culture:en-GB
RUN powershell C:/Windows/System32/inetsrv/appcmd.exe set config /commit:WEBROOT /section:globalization /uiCulture:en-GB
RUN powershell Set-Culture en-GB
RUN powershell Set-WinSystemLocale en-GB
RUN powershell Set-WinHomeLocation -GeoId 242
RUN powershell Set-WinUserLanguageList en-GB -Force
然后构建并运行容器。
docker build -t tmpaspnet .
docker run -it --name tmpcontainer --entrypoint powershell tmpaspnet
# inside the container
Restart-Computer
# container will exit, wait a few seconds
docker start tmpcontainer
docker exec tmpcontainer powershell Get-WinSystemLocale
# verify if system locale is correct set
# commit changes and save them to a new image
docker commit -m 'set system locale to en-GB' tmpcontainer myrepo/aspnet:latest
不幸的是,容器要么忽略了重启并没有完全成功。当我在容器内运行Get-WinSystemLocale
时,“en-US”总是返回。
TL,DR:重启Windows容器的正确方法是什么?
我正在使用以下容器mcr.microsoft.com/dotnet/framework/aspnet:4.7.2
设置语言包https://github.com/sanguedemonstro/docker-playground/blob/master/langpack-on-servercore2019.md时有关失败的其他说明
谢谢