【发布时间】:2020-02-18 04:01:00
【问题描述】:
您好,我正在尝试使用 docker 构建我的 dotnet core 2.1 应用程序。每当我创建项目模板时,都会生成默认的 docker 文件。这个 docker 文件运行良好,但每当我想将它上传到 ecr 时,它都不起作用。所以我改变了docker文件如下。
FROM microsoft/dotnet:2.1-sdk AS build
ENV ASPNETCORE_URLS http://*:44319
EXPOSE 44319
WORKDIR /src
COPY ["LocationServicesAPI/LocationServicesAPI.csproj", "LocationServicesAPI/"]
RUN dotnet restore "LocationServicesAPI/LocationServicesAPI.csproj"
WORKDIR /app/LocationServicesAPI
COPY . .
RUN dotnet build "LocationServicesAPI.csproj" -c Release -o /app
每当我使用 Docker 运行时,都会出现以下错误。
1>Step 9/19 : EXPOSE 44319
1> ---> Using cache
1> ---> 069a0777f156
1>Step 10/19 : WORKDIR /src
1> ---> Using cache
1> ---> 6e9768b88723
1>Step 11/19 : COPY ["LocationServicesAPI/LocationServicesAPI.csproj", "LocationServicesAPI/"]
1> ---> Using cache
1> ---> 37b9e63b9b97
1>Step 12/19 : RUN dotnet restore "LocationServicesAPI/LocationServicesAPI.csproj"
1> ---> Using cache
1>Step 13/19 : WORKDIR /app/LocationServicesAPI
1> ---> f505d07f4d8c
1> ---> Using cache
1> ---> e03aaf3a0d7d
1>Step 14/19 : COPY . .
1> ---> 20b8bb0d74bd
1>Step 15/19 : RUN dotnet build "LocationServicesAPI.csproj" -c Release -o /app
1> ---> Running in f04182972995
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
1>MSBUILD : error MSB1009: Project file does not exist.
1>Switch: LocationServicesAPI.csproj
1>Removing intermediate container f04182972995
1>The command '/bin/sh -c dotnet build "LocationServicesAPI.csproj" -c Release -o /app' returned a non-zero code: 1
1>C:\Users\ngodbole\Documents\MerchWebServices\LocationServicesAPI\LocationServicesAPI\Dockerfile : error CTC1014: Docker command failed with exit code 1.
1>C:\Users\ngodbole\Documents\MerchWebServices\LocationServicesAPI\LocationServicesAPI\Dockerfile : error CTC1014: The command '/bin/sh -c dotnet build "LocationServicesAPI.csproj" -c Release -o /app' returned a non-zero code: 1
1>Done building project "LocationServicesAPI.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
更正路径后出现以下错误。
1> ---> cc58805dac5d
1>Step 14/19 : COPY . .
1> ---> ced094b3788d
1>Step 15/19 : RUN dotnet build LocationServicesAPI.csproj -c Release -o /app
1> ---> Running in 290429a9f4d1
1>Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>Switch: LocationServicesAPI.csproj
1>MSBUILD : error MSB1009: Project file does not exist.
我无法弄清楚。有人可以帮我解决这个问题吗?任何帮助,将不胜感激。谢谢
【问题讨论】:
标签: docker .net-core docker-build