Open Edgaras91 opened 4 months ago
The issue is that IIS is running a different user than the docker user that starts the entrypoint. The docker-iis image uses a helper process as entrypoint (IIS.ServiceMonitor) that reads the environment variables and writes them to IIS config using appcmd, e.g.:
C:\Windows\system32\inetsrv\appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='DefaultAppPool'].environmentVariables.[name='MyVariable',value='MyVariableValue']" /commit:apphost
The asp.net image also uses this same entry point, so I would expect that it would work the same way.
Perhaps you can verify that the updated configuration is indeed written to the applicationHost.config file on startup? Typically it's in system32\inetsrv\config
I have below dockerfile/docker image. When I run
docker run
with environmental variables, they do end up in the container (checked using PowerShell commandGet-Childitem env:
) but the IIS app in inetpub/wwroot is not picking these up (I am usingMicrosoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder
to read these, tested locally using IIS express which works.)I did give a read on this issue: https://github.com/microsoft/iis-docker/issues/75 but I still don't understand why it doesn't work. Could not find any official documentation/examples on environmental variables for framework images.
Could someone explain how to get environmental variables into IIS site using dotnet framework image? My experience comes from dot net core, and I expected it to work similarly.