Joh*_*ros 6 docker docker-for-windows windows-container
我正在尝试从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
Run Code Online (Sandbox Code Playgroud)
然后构建并运行容器。
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
Run Code Online (Sandbox Code Playgroud)
不幸的是,容器要么忽略重启,要么没有完全成功。当我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
谢谢
您确实不应该Restart-Computer
在容器内使用。
如果您需要重新启动它,您甚至不需要在容器内生成 shell。
首先,您需要找到您的容器 ID。要查找容器,您可以使用主机终端中的docker ps
命令。
当您获得容器 ID 后,只需运行docker restart {containerId}
命令即可。
要更改文化,您可以在 web、config 中使用全球化标签,如下所示。
<system.web>
<globalization culture="en-GB" uiCulture="en-GB" />
</system.web>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
632 次 |
最近记录: |