-1

I have specific task,

Docker file that has 2 stages. First stage is dotnet/aspnet:6.0 as base

And then I have dotnet/sdk:6.0 as build stage.

I need PowerShell in this docker container so i could exec some commands after in running container.

Here is dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["somefiles", "dest_folder/"]

RUN dotnet restore "someapi/some_api.csproj"
COPY . .

WORKDIR "dir.Api"
RUN dotnet build "api.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "api.csproj" -c Release -o /app/publish /p:UseAppHost=false

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

So I would like if possible to have PowerShell in this container. Also its Windows docker container.

Already tried many things but nothing seems to work.

P.S. I need PowerShell so I could import always encrypted certificate inside windows certificate store.

Any help would be appreciated!

HugoOlsen
  • 9
  • 3

1 Answers1

0

Are you on a Windows or Linux host. This tag you're using is a multi-arch one, so it will default to the OS you have on the host. What you are doing is possible, but I see a few issues with the docker file you built:

  • The SDK image is larger than the aspnet one, so you should use that one as base.
  • Once you do that, you fix the issue of having multiple states, but your final FROM statement skipping the build one.

For Windows containers, all these images have PowerShell, so I'm assuming you're with wrong tag. Is that the case?