我有一个ASP.net核心Web APP,并希望通过devops IC进行构建,但是这里出现错误:步骤12/13:COPY --from = build-env / app / out。
标志值build-env中的值无效:build-env的拉取访问被拒绝,存储库不存在或可能需要“docker登录”

像这样的dockerfile:

#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat

FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/dotnet:2.1-sdk-nanoserver-1809 AS build
WORKDIR /src
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# Build runtime image
FROM base AS final
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "AzureIoTEdgeWebAPI.dll"]


谢谢你的帮助。

有输出消息

##[section]Starting: Build an image
==============================================================================
Task         : Docker
Description  : Build, tag, push, or run Docker images, or run a Docker command
Version      : 0.154.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/docker
==============================================================================
[command]"C:\Program Files\Docker\docker.exe" build -f d:\a\1\s\AzureIoTEdgeWebAPI\Dockerfile.CI -t boacr001.azurecr.io/azureiotedgewebapi:475 d:\a\1\s\AzureIoTEdgeWebAPI
Sending build context to Docker daemon  65.02kB

Step 1/13 : FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1809 AS base
2.1-aspnetcore-runtime-nanoserver-1809: Pulling from microsoft/dotnet
58fd16eaae0b: Pulling fs layer
c413013f85a3: Pulling fs layer
ba905be336ce: Pulling fs layer
ac3b59bc026d: Pulling fs layer
3cd1d6b69a42: Pulling fs layer
d8f39265b858: Pulling fs layer
ac3b59bc026d: Waiting
3cd1d6b69a42: Waiting
d8f39265b858: Waiting
ba905be336ce: Download complete
c413013f85a3: Verifying Checksum
c413013f85a3: Download complete
ac3b59bc026d: Download complete
58fd16eaae0b: Verifying Checksum
58fd16eaae0b: Download complete
3cd1d6b69a42: Verifying Checksum
3cd1d6b69a42: Download complete
d8f39265b858: Verifying Checksum
d8f39265b858: Download complete
58fd16eaae0b: Pull complete
c413013f85a3: Pull complete
ba905be336ce: Pull complete
ac3b59bc026d: Pull complete
3cd1d6b69a42: Pull complete
d8f39265b858: Pull complete
Digest: sha256:b5e4aa6bb1158474a01f55e75c3c293398ec5d0f77e15eb5b4a5ed144f288bfb
Status: Downloaded newer image for microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1809
 ---> ee932f57c082
Step 2/13 : WORKDIR /app
 ---> Running in e336b66195dd
Removing intermediate container e336b66195dd
 ---> b28b191ac2b1
Step 3/13 : EXPOSE 80
 ---> Running in 220ca3b14c61
Removing intermediate container 220ca3b14c61
 ---> 24fc862171cf
Step 4/13 : FROM microsoft/dotnet:2.1-sdk-nanoserver-1809 AS build
2.1-sdk-nanoserver-1809: Pulling from microsoft/dotnet
58fd16eaae0b: Already exists
e4b0acf5aecf: Pulling fs layer
ee319c56829b: Pulling fs layer
741208d3184c: Pulling fs layer
fdc7b31ffbed: Pulling fs layer
2e630ac6e0d1: Pulling fs layer
97d0e796d516: Pulling fs layer
fdc7b31ffbed: Waiting
2e630ac6e0d1: Waiting
97d0e796d516: Waiting
741208d3184c: Verifying Checksum
741208d3184c: Download complete
ee319c56829b: Verifying Checksum
ee319c56829b: Download complete
2e630ac6e0d1: Verifying Checksum
2e630ac6e0d1: Download complete
fdc7b31ffbed: Verifying Checksum
fdc7b31ffbed: Download complete
e4b0acf5aecf: Verifying Checksum
e4b0acf5aecf: Download complete
97d0e796d516: Verifying Checksum
97d0e796d516: Download complete
e4b0acf5aecf: Pull complete
ee319c56829b: Pull complete
741208d3184c: Pull complete
fdc7b31ffbed: Pull complete
2e630ac6e0d1: Pull complete
97d0e796d516: Pull complete
Digest: sha256:e59728d7acb2c24c32bf6fd2a5123cace1d0cccc92a9676df79725fff31fc950
Status: Downloaded newer image for microsoft/dotnet:2.1-sdk-nanoserver-1809
 ---> 6c225364efec
Step 5/13 : WORKDIR /src
 ---> Running in 51f05a94187b
Removing intermediate container 51f05a94187b
 ---> 34256c0401bd
Step 6/13 : COPY *.csproj ./
 ---> e9acedea268f
Step 7/13 : RUN dotnet restore
 ---> Running in 3aa243264d51
  Restore completed in 12.15 sec for C:\src\AzureIoTEdgeWebAPI.csproj.
Removing intermediate container 3aa243264d51
 ---> 1368a7a61282
Step 8/13 : COPY . ./
 ---> c03a3eb1ec62
Step 9/13 : RUN dotnet publish -c Release -o out
 ---> Running in d6fdc7dda730
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 2.38 sec for C:\src\azureiotedgewebapi.csproj.
IoTEdge.cs(111,17): warning CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call. [C:\src\azureiotedgewebapi.csproj]
IoTEdge.cs(186,30): warning CS0169: The field 'IoTEdge._timer' is never used [C:\src\azureiotedgewebapi.csproj]
  azureiotedgewebapi -> C:\src\bin\Release\netcoreapp2.1\azureiotedgewebapi.dll
  azureiotedgewebapi -> C:\src\out\
Removing intermediate container d6fdc7dda730
 ---> 4512c4cf38d4
Step 10/13 : FROM base AS final
 ---> 24fc862171cf
Step 11/13 : WORKDIR /app
 ---> Running in 3c97ce79e1ce
Removing intermediate container 3c97ce79e1ce
 ---> d71741a67390
Step 12/13 : COPY --from=build-env /app/out .
invalid from flag value build-env: pull access denied for build-env, repository does not exist or may require 'docker login'
##[error]C:\Program Files\Docker\docker.exe failed with return code: 1
##[section]Finishing: Build an image

最佳答案

在此行build-env之前,我看不到任何引用COPY --from=build-env /app/out .的内容,而是看到了对build的引用。我认为将该行更改为COPY --from=build /app/out .应该可以解决您的问题。

关于azure - 生成器拒绝Azure DevOps CI拉访问,存储库不存在或可能需要 'docker login',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57067970/

10-16 02:10