zoukankan      html  css  js  c++  java
  • docker 发布netcore webapi

    新建项目testapi

    新建Dockerfile 文件

    FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-1809 AS base
    WORKDIR /app
    EXPOSE 80
    EXPOSE 443
    
    FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-1809 AS build
    WORKDIR /src
    COPY ["testapi.csproj", ""]
    RUN dotnet restore "./testapi.csproj"
    COPY . .
    WORKDIR "/src/."
    RUN dotnet build "testapi.csproj" -c Release -o /app
    
    FROM build AS publish
    RUN dotnet publish "testapi.csproj" -c Release -o /app
    
    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app .
    ENTRYPOINT ["dotnet", "testapi.dll"]
    

      在项目目录 ctrl+shift 鼠标右键 选择 在此处打开PowrShell

     新建容器: docker build -t testapi:dev .

    运行容器:docker run --name testapi -p 8080:80 -d testapi:dev

    执行:docker ps

     测试连接:curl http://localhost:8080/api/values

    浏览器打开

    发布完成

  • 相关阅读:
    Kafka Kerberos客户端访问
    Kafka Kerberos服务端配置
    Centos安装Kafka
    aaaaaaaaaaaa
    Kafka队列消息和发布订阅消息
    RabbitMQ概念
    RabbitMQ使用
    windows下安装Erlang
    RabbitMQ简介
    Flume简介
  • 原文地址:https://www.cnblogs.com/liaokui/p/11351307.html
Copyright © 2011-2022 走看看