cmd dockerfile 没有执行_为什么容器在CMD(docker)中启动后没有启动?

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值