Skip to content

Docker run -e (enviromental variables) not working. #207

@Edgaras91

Description

@Edgaras91

I have below dockerfile/docker image. When I run docker run with environmental variables, they do end up in the container (checked using PowerShell command Get-Childitem env:) but the IIS app in inetpub/wwroot is not picking these up (I am using Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder to read these, tested locally using IIS express which works.)

I did give a read on this issue: #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.

FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build

EXPOSE 80
EXPOSE 443

WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY ["_Website Application/*.vbproj", "./_Website Application/"]
COPY ["_Website Application/*.config", "./_Website Application/"]
COPY NuGet.config .
RUN nuget restore -ConfigFile NuGet.config

# copy everything else and build app
COPY ["_Website Application/.", "./_Website Application/"]
COPY ["ExternalLibraries/.", "./ExternalLibraries/"]
WORKDIR "/app/_Website Application"
RUN msbuild /p:Configuration=Release -r:False

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8 AS runtime

# Install IIS Rewrite Module
WORKDIR /install
ADD https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi rewrite_amd64_en-US.msi
RUN Write-Host 'Installing URL Rewrite' ; Start-Process msiexec.exe -ArgumentList '/i', 'rewrite_amd64_en-US.msi', '/quiet', '/norestart' -NoNewWindow -Wait;

#Add HTTPS 443 SSL Binding to localhost host name.
COPY docker-enable-localhost-ssl.ps1 .
RUN powershell.exe ./docker-enable-localhost-ssl.ps1

WORKDIR /inetpub/wwwroot
COPY --from=build ["/app/_Website Application/.", "./"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions