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:
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
You really aren't supposed to use Restart-Computer
inside you container.
If you need to restart it, you don't even need to spawn a shell inside you container.
First, you need to find your container id. To find container, you can use the docker ps
command from a host terminal.
When you have your container id, just run the docker restart {containerId}
command.
To change the culture, you can use the globalization tag in your web,config like so.
<system.web>
<globalization culture="en-GB" uiCulture="en-GB" />
</system.web>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With