Docker Community Forums

Share and learn in the Docker community.

.NET Core Windows authentication in docker container


#1

I want to create a container from my .NET Core web application (it consists of multiple projects) which uses Windows Authentication . Here is my Dockerfile :

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk AS build
COPY Solution.sln ./
COPY Project1/*.csproj ./Project1/
COPY Project2/*.csproj ./Project2/
COPY Project3/*.csproj ./Project3/
COPY Project4/*.csproj ./Project4/
COPY Project5/*.csproj ./Project5/

RUN dotnet restore
COPY . .

WORKDIR /Project1
RUN dotnet build -c Release -o /app

WORKDIR /Project2
RUN dotnet build -c Release -o /app

WORKDIR /Project3
RUN dotnet build -c Release -o /app

WORKDIR /Project4
RUN dotnet build -c Release -o /app

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Project4.dll"]

If I run the container, the website opens up but it doesn’t open log in dialogue and user information is missing. What is the easiest way to enable Windows authentication inside Docker container?


(Ove "Lime" Lindström) #2

Windows authentication in Docker is a bit of a pain. It comes down to how Group Managed Service Account (gMSA) works. See https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/hh831782(v=ws.11)

Up until mid 2018, you needed to have an account that matched the container name. Nowadays you do not have to anymore. Take a look at https://www.axians-infoma.de/techblog/windows-authentication-in-docker-containers-just-got-a-lot-easier/ or https://success.docker.com/article/modernizing-traditional-dot-net-applications for more information.