1 Dockerfile 制作镜像
PS:donet:后面的版本后 应该及时查看Docker hub上微软的仓库
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base WORKDIR /app EXPOSE 80 FROM microsoft/dotnet:2.1-sdk AS build WORKDIR /src COPY . . RUN dotnet restore FROM build AS publish RUN dotnet publish -c Release -o /app FROM base AS final WORKDIR /app COPY --from=publish /app . ENTRYPOINT ["dotnet", "User.Api.dll"]
2 docker-compose
PS:使用docker-compose up -d执行
version: '3' services: db: image: microsoft/mssql-server-linux container_name: userapidb ports: - '1433:1433' environment: - ACCEPT_EULA=Y - SA_PASSWORD=Nexel@2018 web: build: . container_name: userapi ports: - '82:80' depends_on: - db