首页 > 解决方案 > 当文件存在时,Docker Build 会抛出文件未找到错误

问题描述

每次我尝试复制Brevity.Api.xml时,它总是会以“未找到”问题告终,并会导致构建失败。在执行复制指令之前列出 docker build 所在目录中的文件表明该文件确实存在。我错过了什么?检查构建日志中的第 11 步(在日志底部)

Pulling cache layers for index.docker.io/Brevitydata/Brevity-api:0.4.43...
Done!
KernelVersion: 4.4.0-1060-aws
Components: [{u'Version': u'18.03.1-ee-3', u'Name': u'Engine', u'Details': {u'KernelVersion': u'4.4.0-1060-aws', u'Os': u'linux', u'BuildTime': u'2018-08-30T18:42:30.000000000+00:00', u'ApiVersion': u'1.37', u'MinAPIVersion': u'1.12', u'GitCommit': u'b9a5c95', u'Arch': u'amd64', u'Experimental': u'false', u'GoVersion': u'go1.10.2'}}]
Arch: amd64
BuildTime: 2018-08-30T18:42:30.000000000+00:00
ApiVersion: 1.37
Platform: {u'Name': u''}
Version: 18.03.1-ee-3
MinAPIVersion: 1.12
GitCommit: b9a5c95
Os: linux
GoVersion: go1.10.2
Starting build of index.docker.io/Brevitydata/Brevity-api:0.4.49...
Step 1/12 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
---> 1742a2119970
Step 2/12 : WORKDIR /app
Removing intermediate container 887fcd1e995e
---> bac77da95fad
Step 3/12 : COPY . .
---> 009da497612e
Step 4/12 : RUN dotnet restore Brevity.Api/Brevity.Api.csproj
---> Running in 5ba2d2896e6d
Restore completed in 40.71 sec for /app/Brevity.Repo/Brevity.Repo.csproj.
Restore completed in 552.05 ms for /app/Brevity.Repo.BCL/Brevity.Repo.BCL.csproj.
Restore completed in 7.57 sec for /app/Brevity.Repo.Auth/Brevity.Repo.Auth.csproj.
Restore completed in 743.11 ms for /app/Brevity.Infra.Service/Brevity.Infra.Service.csproj.
Restore completed in 712.74 ms for /app/Brevity.Infra.Preprocessing/Brevity.Infra.Preprocessing.csproj.
Restore completed in 611.66 ms for /app/Brevity.Infra.Auth/Brevity.Infra.Auth.csproj.
Restore completed in 2.25 sec for /app/Brevity.Infra.Api.Limiter/Brevity.Infra.Api.Limiter.csproj.
Restore completed in 432.34 ms for /app/Brevity.Base.Domain/Brevity.Base.Domain.csproj.
Restore completed in 416.64 ms for /app/Brevity.Base.BCL/Brevity.Base.BCL.csproj.
Restore completed in 423.75 ms for /app/Brevity.Base.Auth/Brevity.Base.Auth.csproj.
Restore completed in 1.56 sec for /app/Brevity.Api/Brevity.Api.csproj.
Removing intermediate container 5ba2d2896e6d
---> 23c6d213de70
Step 5/12 : COPY . ./
---> 6f89563fb030
Step 6/12 : RUN dotnet publish Brevity.Api/Brevity.Api.csproj -c Release -o out
---> Running in d78bf8192d4e
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 240.18 ms for /app/Brevity.Repo/Brevity.Repo.csproj.
Restore completed in 2.13 ms for /app/Brevity.Repo.BCL/Brevity.Repo.BCL.csproj.
Restore completed in 35.24 ms for /app/Brevity.Repo.Auth/Brevity.Repo.Auth.csproj.
Restore completed in 3.16 ms for /app/Brevity.Infra.Service/Brevity.Infra.Service.csproj.
Restore completed in 14.94 ms for /app/Brevity.Infra.Preprocessing/Brevity.Infra.Preprocessing.csproj.
Restore completed in 11.43 ms for /app/Brevity.Infra.Auth/Brevity.Infra.Auth.csproj.
Restore completed in 31.84 ms for /app/Brevity.Infra.Api.Limiter/Brevity.Infra.Api.Limiter.csproj.
Restore completed in 1.64 ms for /app/Brevity.Base.Domain/Brevity.Base.Domain.csproj.
Restore completed in 1.58 ms for /app/Brevity.Base.BCL/Brevity.Base.BCL.csproj.
Restore completed in 1.9 ms for /app/Brevity.Base.Auth/Brevity.Base.Auth.csproj.
Restore completed in 3.69 ms for /app/Brevity.Api/Brevity.Api.csproj.
Brevity.Base.BCL -> /app/Brevity.Base.BCL/bin/Release/netcoreapp3.1/Brevity.Base.BCL.dll
Brevity.Base.Auth -> /app/Brevity.Base.Auth/bin/Release/netcoreapp3.1/Brevity.Base.Auth.dll
ViewModels/WebsocketCommand/WebsocketCommandViewModel.cs(15,13): warning CS0612: 'WebsocketCommandViewModel.Id' is obsolete [/app/Brevity.Base.Domain/Brevity.Base.Domain.csproj]
ViewModels/WebsocketCommand/UpdateWebsocketCommandInputModel.cs(20,30): warning CS0612: 'WebsocketCommandViewModel.Id' is obsolete [/app/Brevity.Base.Domain/Brevity.Base.Domain.csproj]
ViewModels/WebsocketCommand/UpdateWebsocketCommandInputModel.cs(25,34): warning CS0612: 'WebsocketCommandViewModel.Id' is obsolete [/app/Brevity.Base.Domain/Brevity.Base.Domain.csproj]
Brevity.Base.Domain -> /app/Brevity.Base.Domain/bin/Release/netcoreapp3.1/Brevity.Base.Domain.dll
Created package at /app/Brevity.Base.Domain/bin/Release/Brevity.Data.1.0.0.nupkg.
Brevity.Repo.BCL -> /app/Brevity.Repo.BCL/bin/Release/netcoreapp3.1/Brevity.Repo.BCL.dll
Brevity.Repo.Auth -> /app/Brevity.Repo.Auth/bin/Release/netcoreapp3.1/Brevity.Repo.Auth.dll
Brevity.Repo -> /app/Brevity.Repo/bin/Release/netcoreapp3.1/Brevity.Repo.dll
Brevity.Infra.Preprocessing -> /app/Brevity.Infra.Preprocessing/bin/Release/netcoreapp3.1/Brevity.Infra.Preprocessing.dll
Brevity.Api -> /app/Brevity.Api/bin/Release/netcoreapp3.1/Brevity.Api.dll
Brevity.Api -> /app/out/
Removing intermediate container d78bf8192d4e
---> fc7bab01292f
Step 7/12 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
---> 49a8777ecaba
Step 8/12 : WORKDIR /app
---> Using cache
---> b5e9eed15764
Step 9/12 : COPY --from=build-env /app/out .
---> 6627192f71e4
Step 10/12 : RUN ls
---> Running in 1434f9853080
FluentValidation.AspNetCore.dll
FluentValidation.DependencyInjectionExtensions.dll
FluentValidation.dll
IdentityModel.dll
IdentityServer4.AspNetIdentity.dll
IdentityServer4.Storage.dll
IdentityServer4.dll
Microsoft.AspNetCore.Authentication.OpenIdConnect.dll
Microsoft.AspNetCore.Cryptography.Internal.dll
Microsoft.AspNetCore.Cryptography.KeyDerivation.dll
Microsoft.AspNetCore.Identity.EntityFrameworkCore.dll
Microsoft.AspNetCore.JsonPatch.dll
Microsoft.AspNetCore.Mvc.NewtonsoftJson.dll
Microsoft.Bcl.AsyncInterfaces.dll
Microsoft.Bcl.HashCode.dll
Microsoft.DotNet.PlatformAbstractions.dll
Microsoft.EntityFrameworkCore.Abstractions.dll
Microsoft.EntityFrameworkCore.Design.dll
Microsoft.EntityFrameworkCore.Relational.dll
Microsoft.EntityFrameworkCore.dll
Microsoft.Extensions.Caching.Abstractions.dll
Microsoft.Extensions.Caching.Memory.dll
Microsoft.Extensions.Caching.StackExchangeRedis.dll
Microsoft.Extensions.Configuration.Abstractions.dll
Microsoft.Extensions.Configuration.Binder.dll
Microsoft.Extensions.Configuration.dll
Microsoft.Extensions.DependencyInjection.Abstractions.dll
Microsoft.Extensions.DependencyInjection.dll
Microsoft.Extensions.DependencyModel.dll
Microsoft.Extensions.FileProviders.Abstractions.dll
Microsoft.Extensions.Hosting.Abstractions.dll
Microsoft.Extensions.Identity.Core.dll
Microsoft.Extensions.Identity.Stores.dll
Microsoft.Extensions.Logging.Abstractions.dll
Microsoft.Extensions.Logging.dll
Microsoft.Extensions.Options.dll
Microsoft.Extensions.Primitives.dll
Microsoft.IdentityModel.JsonWebTokens.dll
Microsoft.IdentityModel.Logging.dll
Microsoft.IdentityModel.Protocols.OpenIdConnect.dll
Microsoft.IdentityModel.Protocols.dll
Microsoft.IdentityModel.Tokens.dll
Microsoft.OpenApi.dll
NCalc.dll
Newtonsoft.Json.Bson.dll
Newtonsoft.Json.dll
Brevity.Api
Brevity.Api.deps.json
Brevity.Api.dll
Brevity.Api.pdb
Brevity.Api.runtimeconfig.json
Brevity.Api.xml
Brevity.Base.Auth.dll
Brevity.Base.Auth.pdb
Brevity.Base.BCL.dll
Brevity.Base.BCL.pdb
Brevity.Base.Domain.dll
Brevity.Base.Domain.pdb
Brevity.Infra.Api.Limiter.dll
Brevity.Infra.Api.Limiter.pdb
Brevity.Infra.Auth.dll
Brevity.Infra.Auth.pdb
Brevity.Infra.Preprocessing.dll
Brevity.Infra.Preprocessing.pdb
Brevity.Infra.Service.dll
Brevity.Infra.Service.pdb
Brevity.Repo.Auth.dll
Brevity.Repo.Auth.pdb
Brevity.Repo.BCL.dll
Brevity.Repo.BCL.pdb
Brevity.Repo.dll
Brevity.Repo.pdb
Npgsql.EntityFrameworkCore.PostgreSQL.dll
Npgsql.dll
Pipelines.Sockets.Unofficial.dll
Polly.dll
Scrutor.dll
SendGrid.dll
Serilog.AspNetCore.dll
Serilog.Extensions.Hosting.dll
Serilog.Extensions.Logging.dll
Serilog.Formatting.Compact.dll
Serilog.Settings.Configuration.dll
Serilog.Sinks.Console.dll
Serilog.Sinks.Debug.dll
Serilog.Sinks.File.dll
Serilog.dll
StackExchange.Redis.dll
Stripe.net.dll
Swashbuckle.AspNetCore.Annotations.dll
Swashbuckle.AspNetCore.Filters.dll
Swashbuckle.AspNetCore.Swagger.dll
Swashbuckle.AspNetCore.SwaggerGen.dll
Swashbuckle.AspNetCore.SwaggerUI.dll
System.Configuration.ConfigurationManager.dll
System.Diagnostics.PerformanceCounter.dll
System.IdentityModel.Tokens.Jwt.dll
System.Security.Cryptography.ProtectedData.dll
VaultSharp.dll
appsettings.Development.json
appsettings.json
runtimes
web.config
Removing intermediate container 1434f9853080
---> de41029bd7bf
Step 11/12 : COPY Brevity.pfx Brevity.Api.xml .
COPY failed: stat /var/lib/docker/tmp/docker-builder345555611/Brevity.Api.xml: no such file or directory

标签: docker.net-coredockerfiledevopsdockerhub

解决方案


如果文件已经存在于容器中,那么为什么要再次尝试复制它?

COPY命令用于将文件从主机复制到映像。


推荐阅读