I'm trying to run a legacy ASP.Net (.Net 4.7.1) application from a Windows container. One of the requirements is to have the system culture, locale and location set to en-GB. I'm not allowed to touch the code, only the web.config if absolutely needed.
In consideration is the following approach:
- create a base image containing all certificates, and culture setting applied (restart is required)
- restart base image (either using Windows restart or Container restart, whatever works)
- run the base image to ensure the culture settings are correctly applied
- save base image
- create a new image containing my application, using the base image previously generated
Dockerfile of my base image is:
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
Then build and run the container.
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
Unfortunately, the container either ignores the Restart does not not completely successfully. When I run Get-WinSystemLocale
inside the container "en-US" is always returned.
TL,DR: What is the correct way to restart a Windows Container?
I'm using the following container mcr.microsoft.com/dotnet/framework/aspnet:4.7.2
Additional notes regarding failures while setting language pack https://github.com/sanguedemonstro/docker-playground/blob/master/langpack-on-servercore2019.md
Thanks