dotnet coreDocker 应用入门

    xiaoxiao2024-10-18  77

    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

    最新回复(0)