1 创建console项目
dotnet new console --output helloworld
2 编译项目
dotnet build
3 运行项目
dotnet run
这个项目就建好了。然后建里Dockerfile。内容如下:
FROM microsoft/dotnet:3.0-sdk
WORKDIR /app
# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# copy and build everything else
COPY . ./
RUN dotnet publish -c Release -o out
ENTRYPOINT ["dotnet", "out/helloworld.dll"]
执行Docker指令
docker build -t myhello-dev .
执行Docker指令运行
docker run myhello-dev