首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当文件存在时,Docker Build抛出未找到的文件。

当文件存在时,Docker Build抛出未找到的文件。
EN

Stack Overflow用户
提问于 2020-03-22 14:01:18
回答 2查看 1.5K关注 0票数 0

每次我试图复制Brevity.Api.xml时,总是会出现一个“Not”问题,并且会导致构建失败。在执行复制指令之前,列出停靠程序构建所在的目录中的文件,显示文件确实存在。我遗漏了什么?检查构建日志中的步骤11 (在日志底部)

代码语言:javascript
复制
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

没有其他的对接配置,比如.dockerignore.

  • All构建是在docker上完成的。
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-03-22 18:19:10

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

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

票数 2
EN

Stack Overflow用户

发布于 2020-03-22 23:06:14

COPY不复制图像中的文件。它将文件从一个主机复制到另一个图像。

当您执行RUN ls时,您位于文件所在的图像中,而当前的工作目录是映像中的/app。也就是说,图像中的/app目录包含.xml file

现在,如果要将其复制到映像中的其他地方,则需要在映像中执行RUN copy命令。

因此,将命令11更改如下。

代码语言:javascript
复制
RUN copy Brevity.pfx "destination directory within the image"
RUN copy Brevity.Api.xml "destination directory within the image"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60800252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档