gpt4 book ai didi

来自 IFSC 代码的 Azure Devops Docker 镜像没有这样的文件或目录

转载 作者:行者123 更新时间:2023-12-02 22:51:54 26 4
gpt4 key购买 nike

目标是将图像推送到 dockerhub,这在 Visual Studio 的“发布”功能中效果很好。

我有这个 Dockerfile:


FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj", "DockerTestWebsiteLinux/"]
RUN dotnet restore "DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj"
COPY . .
WORKDIR "/src/DockerTestWebsiteLinux"
RUN dotnet build "DockerTestWebsiteLinux.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "DockerTestWebsiteLinux.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "DockerTestWebsiteLinux.dll"]

这是使用 VS2019 最新版本生成的空白 ASP.NET Core 项目的默认项目。

管道 YAML 如下所示:

steps:
- task: Docker@0
displayName: 'Build an image'
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryConnection: 'docker hub jc'
dockerFile: DockerTestWebsiteLinux/Dockerfile

(这是当您单击“Docker”作为作业时出现的默认项目,我只更改了 dockerfile 的路径,因为它是解决方案中众多项目中的一个)

他似乎发现 Dockerfile 很好,但随后存在

Step 6/16 : COPY ["DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj", "DockerTestWebsiteLinux/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder071437444/DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj: no such file or directory
##[error]COPY failed: stat /var/lib/docker/tmp/docker-builder071437444/DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj: no such file or directory
##[error]/usr/bin/docker failed with return code: 1

我做错了什么?

完整日志是:

2020-06-12T11:19:12.4891643Z ##[section]Starting: Build an image
2020-06-12T11:19:12.4903893Z ==============================================================================
2020-06-12T11:19:12.4904229Z Task : Docker
2020-06-12T11:19:12.4904567Z Description : Build, tag, push, or run Docker images, or run a Docker command
2020-06-12T11:19:12.4904871Z Version : 0.157.2
2020-06-12T11:19:12.4905150Z Author : Microsoft Corporation
2020-06-12T11:19:12.4905502Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/docker
2020-06-12T11:19:12.4905906Z ==============================================================================
2020-06-12T11:19:12.9134260Z c99ab064-584c-4340-b58e-7a19ca76f6b8 exists true
2020-06-12T11:19:12.9842066Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9842743Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9843349Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9843985Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9844543Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9845090Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9845644Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9846187Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9846740Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9847280Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9847830Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9848370Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9848914Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9849468Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9850017Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9850568Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9851111Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9851662Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9852200Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9852750Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9853292Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9853843Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9854385Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9855199Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9859182Z [command]/usr/bin/docker build -f /home/vsts/work/9/s/DockerTestWebsiteLinux/Dockerfile -t mlatwork:256 /home/vsts/work/9/s/DockerTestWebsiteLinux
2020-06-12T11:19:13.4004892Z Sending build context to Docker daemon 11.78kB
2020-06-12T11:19:13.4005606Z
2020-06-12T11:19:13.4565372Z Step 1/16 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
2020-06-12T11:19:13.6021599Z 3.1-buster-slim: Pulling from dotnet/core/aspnet
2020-06-12T11:19:13.6038540Z 8559a31e96f4: Pulling fs layer
2020-06-12T11:19:13.6044182Z dc08029e21f9: Pulling fs layer
2020-06-12T11:19:13.6044508Z 734d0e250adf: Pulling fs layer
2020-06-12T11:19:13.6044768Z 84249fbd30d6: Pulling fs layer
2020-06-12T11:19:13.6045041Z 84d07bfbfd3f: Pulling fs layer
2020-06-12T11:19:13.6045286Z 84249fbd30d6: Waiting
2020-06-12T11:19:13.6045529Z 84d07bfbfd3f: Waiting
2020-06-12T11:19:13.6905803Z 734d0e250adf: Download complete
2020-06-12T11:19:13.8902364Z dc08029e21f9: Verifying Checksum
2020-06-12T11:19:13.8904333Z dc08029e21f9: Download complete
2020-06-12T11:19:13.9788197Z 8559a31e96f4: Verifying Checksum
2020-06-12T11:19:13.9793870Z 8559a31e96f4: Download complete
2020-06-12T11:19:14.0424733Z 84249fbd30d6: Verifying Checksum
2020-06-12T11:19:14.0429176Z 84249fbd30d6: Download complete
2020-06-12T11:19:14.0836902Z 84d07bfbfd3f: Verifying Checksum
2020-06-12T11:19:14.0846946Z 84d07bfbfd3f: Download complete
2020-06-12T11:19:15.1361383Z 8559a31e96f4: Pull complete
2020-06-12T11:19:15.7092876Z dc08029e21f9: Pull complete
2020-06-12T11:19:15.8149265Z 734d0e250adf: Pull complete
2020-06-12T11:19:16.5138806Z 84249fbd30d6: Pull complete
2020-06-12T11:19:16.7693218Z 84d07bfbfd3f: Pull complete

2020-06-12T11:19:16.7722239Z Digest: sha256:b5ca2387bc65608bed936c04f40ddd92e8b6a5a3387f38a210e18d531080f2ca
2020-06-12T11:19:16.7751385Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim
2020-06-12T11:19:16.7759194Z ---> 7e3fe71c7693
2020-06-12T11:19:16.7759605Z Step 2/16 : WORKDIR /app
2020-06-12T11:19:20.0241824Z ---> Running in 5f40e0c57f8f
2020-06-12T11:19:21.0254992Z Removing intermediate container 5f40e0c57f8f
2020-06-12T11:19:21.0256309Z ---> 781ae87ed64e
2020-06-12T11:19:21.0256726Z Step 3/16 : EXPOSE 80
2020-06-12T11:19:21.0753001Z ---> Running in f63a9f7f81a0
2020-06-12T11:19:22.0301005Z Removing intermediate container f63a9f7f81a0
2020-06-12T11:19:22.0302213Z ---> 7a89f78b321c
2020-06-12T11:19:22.0302737Z Step 4/16 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
2020-06-12T11:19:22.1082117Z 3.1-buster: Pulling from dotnet/core/sdk
2020-06-12T11:19:22.1082686Z e9afc4f90ab0: Pulling fs layer
2020-06-12T11:19:22.1083039Z 989e6b19a265: Pulling fs layer
2020-06-12T11:19:22.1083406Z af14b6c2f878: Pulling fs layer
2020-06-12T11:19:22.1083748Z 5573c4b30949: Pulling fs layer
2020-06-12T11:19:22.1084108Z 17f039feca24: Pulling fs layer
2020-06-12T11:19:22.1084451Z a739c871edc6: Pulling fs layer
2020-06-12T11:19:22.1084919Z 8d7e6a1ea13e: Pulling fs layer
2020-06-12T11:19:22.1085152Z 17f039feca24: Waiting
2020-06-12T11:19:22.1085370Z a739c871edc6: Waiting
2020-06-12T11:19:22.1085614Z 8d7e6a1ea13e: Waiting
2020-06-12T11:19:22.1085832Z 5573c4b30949: Waiting
2020-06-12T11:19:22.2752636Z 989e6b19a265: Verifying Checksum
2020-06-12T11:19:22.2753050Z 989e6b19a265: Download complete
2020-06-12T11:19:22.2890385Z af14b6c2f878: Verifying Checksum
2020-06-12T11:19:22.2890748Z af14b6c2f878: Download complete
2020-06-12T11:19:22.4478115Z 17f039feca24: Verifying Checksum
2020-06-12T11:19:22.4478471Z 17f039feca24: Download complete
2020-06-12T11:19:22.7472123Z e9afc4f90ab0: Verifying Checksum
2020-06-12T11:19:22.7472472Z e9afc4f90ab0: Download complete
2020-06-12T11:19:22.9057708Z 5573c4b30949: Verifying Checksum
2020-06-12T11:19:22.9059825Z 5573c4b30949: Download complete
2020-06-12T11:19:23.0119160Z 8d7e6a1ea13e: Verifying Checksum
2020-06-12T11:19:23.0120321Z 8d7e6a1ea13e: Download complete
2020-06-12T11:19:23.7463177Z a739c871edc6: Verifying Checksum
2020-06-12T11:19:23.7464827Z a739c871edc6: Download complete
2020-06-12T11:19:24.9514807Z e9afc4f90ab0: Pull complete
2020-06-12T11:19:25.2664959Z 989e6b19a265: Pull complete
2020-06-12T11:19:25.5500940Z af14b6c2f878: Pull complete
2020-06-12T11:19:27.5001594Z 5573c4b30949: Pull complete
2020-06-12T11:19:27.8404155Z 17f039feca24: Pull complete
2020-06-12T11:19:31.4556340Z a739c871edc6: Pull complete
2020-06-12T11:19:31.9511844Z 8d7e6a1ea13e: Pull complete
2020-06-12T11:19:31.9534709Z Digest: sha256:1616a64f2eb95e1d9bc0f7185cff16aa44ce0f63c8f61d6bebac5f810d580711
2020-06-12T11:19:31.9550718Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1-buster
2020-06-12T11:19:31.9558815Z ---> 5f369f0d8192
2020-06-12T11:19:31.9559092Z Step 5/16 : WORKDIR /src
2020-06-12T11:19:40.3165947Z ---> Running in 9d104c6e7d2b
2020-06-12T11:19:41.0594271Z Removing intermediate container 9d104c6e7d2b
2020-06-12T11:19:41.0595329Z ---> d49cec115c36
2020-06-12T11:19:41.0595671Z Step 6/16 : COPY ["DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj", "DockerTestWebsiteLinux/"]
2020-06-12T11:19:41.0596514Z COPY failed: stat /var/lib/docker/tmp/docker-builder071437444/DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj: no such file or directory
2020-06-12T11:19:41.0645016Z ##[error]COPY failed: stat /var/lib/docker/tmp/docker-builder071437444/DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj: no such file or directory
2020-06-12T11:19:41.0800905Z ##[error]/usr/bin/docker failed with return code: 1
2020-06-12T11:19:41.0837329Z ##[section]Finishing: Build an image

编辑:我使问题更具可重现性:

1) 创建一个具有 Docker 支持的空 ASP.NET Core 项目2) 将该项目上传到 Azure Devops GIT 存储库3)创建管道,选择“Docker build”作为任务

默认管道如下所示:

# Docker
# Build a Docker image
# https://learn.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- master

resources:
- repo: self

variables:
tag: '$(Build.BuildId)'

stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
displayName: Build an image
inputs:
command: build
dockerfile: '$(Build.SourcesDirectory)/AzureDevopsDockerTest/Dockerfile'
tags: |
$(tag)

但它仍然存在:

Step 7/26 : COPY ["AzureDevopsDockerTest/AzureDevopsDockerTest.csproj", "AzureDevopsDockerTest/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder580556181/AzureDevopsDockerTest/AzureDevopsDockerTest.csproj: no such file or directory
##[error]COPY failed: stat /var/lib/docker/tmp/docker-builder580556181/AzureDevopsDockerTest/AzureDevopsDockerTest.csproj: no such file or directory
##[error]The process '/usr/bin/docker' failed with exit code 1

本例中的 dockerfile:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["AzureDevopsDockerTest/AzureDevopsDockerTest.csproj", "AzureDevopsDockerTest/"]
RUN dotnet restore "AzureDevopsDockerTest/AzureDevopsDockerTest.csproj"
COPY . .
WORKDIR "/src/AzureDevopsDockerTest"
RUN dotnet build "AzureDevopsDockerTest.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "AzureDevopsDockerTest.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AzureDevopsDockerTest.dll"]

最佳答案

最好的方法(对我也有用)是避免任何硬编码并使用上下文,如下例所示:

buildContext: $(Build.Repository.LocalPath)

关于来自 IFSC 代码的 Azure Devops Docker 镜像没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62343444/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com