First I create an image of project then create container then I want to start it
but after starting the container it exits
. why it says " Exited (145) 2 seconds ago " for started container?
check the image
I did what @Jamie said
this is the result :
PM> docker run myimage -d
docker : Did you mean to run dotnet SDK commands? Please install dotnet SDK
from:
At line:1 char:1
+ docker run myimage -d
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Did you mean to...otnet SDK
from::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
DockerFile :
I am using this tutorial :
This
I did what @Pierre said . this is the result
(No change)
解决方案
the issue was related to my docker file :
I created another project
I followed this tutorial :tutorial
I used the docker file in mentioned link and modified it a little bit based on my project needs.
FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1709 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM microsoft/dotnet:2.2-sdk-nanoserver-1709 AS build
WORKDIR /src
COPY ./wa2.csproj ./
RUN dotnet restore
COPY . .
WORKDIR /src
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", "wa2.dll"]
Then I created image from project
$ docker build -t myimage2 -f Dockerfile .
(I had to switch to windows container from docker as mentioned here
I faced a weird error which will be solved by help of this link
(By the way, VPN was also Off)
The mentioned error on building image. This is the error line "RUN dotnet restor"
then I executed these two line on command in project folder
// create container
$ docker build -t (project name) .
// run container
$ docker run -d -p 8080:80 --name (container name) (project name)
the container is created and I could run it. then I could see the result from 2 port one from Visual studio another from Docker