我设法在Windows 10计算机上的容器中设置了一个asp.net core(2.2)应用程序,并且可以在浏览器中浏览该应用程序。但是,我无法按以下说明对容器进行Powershell操作:Running powershell or cmd on docker container。
docker exec -it 723b19acf1d6 powershell
我在Powershell中遇到错误:
container 723b19acf1d6a796812832dff82c2240af465d9100ade64d9ff95afce1a4267b encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(174)\vmcomputeagent.exe!00007FF7E0C2C00A: (caller: 00007FF7E0BFECEA) Exception(9) tid(580) 80070002 The system cannot find the file specified.
CallContext:[\Bridge_ProcessMessage\ComputeSystemManager_ExecuteProcess\VmHostedContainer_ExecuteProcess]
Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"powershell","User":"ContainerUser","WorkingDirectory":"C:\\app","Environment":{"ASPNETCORE_URLS":"http://+:80","DOTNET_RUNNING_IN_CONTAINER":"true"},"EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[0,0]}
我用来设置容器的运行命令:
docker run -p 8081:443 -p 8080:80 -h myweb -v D:\Learn\DockerTrials\APITest\APITest:c:\temp apitest
Dockerfile:
#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat
FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1803 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
COPY certificate.ps1 .
FROM microsoft/dotnet:2.2-sdk-nanoserver-1803 AS build
WORKDIR /src
COPY ["APITest.csproj", "APITest/"]
RUN dotnet restore "APITest/APITest.csproj"
COPY . ./
RUN dotnet build "APITest.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "APITest.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "APITest.dll"]
我正在尝试通过按照以下说明运行powershell文件来设置https:https://blogs.msdn.microsoft.com/zxue/2016/12/19/adding-https-support-to-individual-windows-containers-using-self-issued-certificates/
答案 0 :(得分:0)
From Microsoft community forum:
Microsoft从基本nanoserver中删除了powershell和其他组件 图片。您需要使用带有内置Powershell的图像。