Azure devops Azure pipelines Docker任务向Docker守护程序发送零构建上下文

Azure devops Azure pipelines Docker任务向Docker守护程序发送零构建上下文,azure-devops,azure-pipelines,Azure Devops,Azure Pipelines,以下是我的示例项目: Dockerfile只有3行: FROM microsoft/aspnet@sha256:51fdd2a971dcc07d670da477a2f0d6d3c0a6872ea3f0f89226b98b62ccb1c2a1 WORKDIR /inetpub/wwwroot COPY . . 我正在使用带有VS2019的托管Windows 2019作为构建代理。当我配置docker build任务时,队列会将其删除。以下是调试日志: ##[debug]Evaluating co

以下是我的示例项目:

Dockerfile
只有3行:

FROM microsoft/aspnet@sha256:51fdd2a971dcc07d670da477a2f0d6d3c0a6872ea3f0f89226b98b62ccb1c2a1
WORKDIR /inetpub/wwwroot
COPY . .
我正在使用带有VS2019的托管Windows 2019作为构建代理。当我配置docker build任务时,队列会将其删除。以下是调试日志:

##[debug]Evaluating condition for step: 'Build an image'
##[debug]Evaluating: succeeded()
##[debug]Evaluating succeeded:
##[debug]=> True
##[debug]Result: True
##[section]Starting: Build an image
==============================================================================
Task         : Docker
Description  : Build, tag, push, or run Docker images, or run a Docker command. Task can be used with Docker or Azure Container registry.
Version      : 0.150.5
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=848006)
==============================================================================
##[debug]agent.workFolder=d:\a
##[debug]loading inputs and endpoints
##[debug]loading ENDPOINT_AUTH_0a60651a-d339-4880-b2be-57c5d567f97e
##[debug]loading ENDPOINT_AUTH_PARAMETER_0a60651a-d339-4880-b2be-57c5d567f97e_AUTHENTICATIONTYPE
##[debug]loading ENDPOINT_AUTH_PARAMETER_0a60651a-d339-4880-b2be-57c5d567f97e_SERVICEPRINCIPALID
##[debug]loading ENDPOINT_AUTH_PARAMETER_0a60651a-d339-4880-b2be-57c5d567f97e_SERVICEPRINCIPALKEY
##[debug]loading ENDPOINT_AUTH_PARAMETER_0a60651a-d339-4880-b2be-57c5d567f97e_TENANTID
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading ENDPOINT_AUTH_SCHEME_0a60651a-d339-4880-b2be-57c5d567f97e
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading INPUT_ACTION
##[debug]loading INPUT_AZURECONTAINERREGISTRY
##[debug]loading INPUT_AZURESUBSCRIPTIONENDPOINT
##[debug]loading INPUT_CONTAINERREGISTRYTYPE
##[debug]loading INPUT_CONTEXT
##[debug]loading INPUT_CWD
##[debug]loading INPUT_DEFAULTCONTEXT
##[debug]loading INPUT_DETACHED
##[debug]loading INPUT_DOCKERFILE
##[debug]loading INPUT_ENFORCEDOCKERNAMINGCONVENTION
##[debug]loading INPUT_IMAGEDIGESTFILE
##[debug]loading INPUT_IMAGENAME
##[debug]loading INPUT_IMAGENAMESPATH
##[debug]loading INPUT_INCLUDELATESTTAG
##[debug]loading INPUT_INCLUDESOURCETAGS
##[debug]loading INPUT_QUALIFYIMAGENAME
##[debug]loading INPUT_RESTARTPOLICY
##[debug]loaded 26
##[debug]check path : d:\a\_tasks\Docker_e28912f1-0114-4464-802a-a3a35437fd16\0.150.5\task.json
##[debug]set resource file to: d:\a\_tasks\Docker_e28912f1-0114-4464-802a-a3a35437fd16\0.150.5\task.json
##[debug]system.culture=en-US
##[debug]cwd=d:\a\1\s\WebApplication1
##[debug]containerregistrytype=Azure Container Registry
##[debug]azureSubscriptionEndpoint=0a60651a-d339-4880-b2be-57c5d567f97e
##[debug]azureContainerRegistry={"loginServer":"moderndotnet.azurecr.io", "id" : "/subscriptions/6d2fcc60-715d-41ab-a5f2-6923c826436d/resourceGroups/ModernDotNetDev/providers/Microsoft.ContainerRegistry/registries/moderndotnet"}
##[debug]Reading the acr registry in old versions
##[debug]0a60651a-d339-4880-b2be-57c5d567f97e auth param serviceprincipalid = ***
##[debug]0a60651a-d339-4880-b2be-57c5d567f97e auth param serviceprincipalkey = ***
##[debug]System.ServerType=Hosted
##[debug]Processed: ##vso[task.setvariable variable=CONTAINER_USERNAME;issecret=true;]***
##[debug]Processed: ##vso[task.setvariable variable=CONTAINER_PASSWORD;issecret=true;]***
##[debug]Absolute path for pathSegments: C:\agents\2.150.0\externals\git\cmd/docker = C:\agents\2.150.0\externals\git\cmd\docker
##[debug]Absolute path for pathSegments: C:/hostedtoolcache/windows/Python/3.6.8/x64/docker = C:\hostedtoolcache\windows\Python\3.6.8\x64\docker
##[debug]Absolute path for pathSegments: C:/hostedtoolcache/windows/Python/3.6.8/x64/Scripts/docker = C:\hostedtoolcache\windows\Python\3.6.8\x64\Scripts\docker
##[debug]Absolute path for pathSegments: C:\cf-cli/docker = C:\cf-cli\docker
##[debug]Absolute path for pathSegments: C:\Program Files (x86)\NSIS\/docker = C:\Program Files (x86)\NSIS\docker
##[debug]Absolute path for pathSegments: C:\Program Files\Boost\1.69.0/docker = C:\Program Files\Boost\1.69.0\docker
##[debug]Absolute path for pathSegments: C:\Users\VssAdministrator\.dotnet\tools/docker = C:\Users\VssAdministrator\.dotnet\tools\docker
##[debug]Absolute path for pathSegments: C:\Program Files\dotnet/docker = C:\Program Files\dotnet\docker
##[debug]Absolute path for pathSegments: C:\mysql-5.7.21-winx64\bin/docker = C:\mysql-5.7.21-winx64\bin\docker
##[debug]Absolute path for pathSegments: C:\Program Files\Java\zulu-8-azure-jdk_8.36.0.1-8.0.202-win_x64\bin/docker = C:\Program Files\Java\zulu-8-azure-jdk_8.36.0.1-8.0.202-win_x64\bin\docker
##[debug]Absolute path for pathSegments: C:\npm\prefix/docker = C:\npm\prefix\docker
##[debug]Absolute path for pathSegments: C:\hostedtoolcache\windows\Ruby\2.5.0\x64\bin/docker = C:\hostedtoolcache\windows\Ruby\2.5.0\x64\bin\docker
##[debug]Absolute path for pathSegments: C:\Go1.12.1\bin/docker = C:\Go1.12.1\bin\docker
##[debug]Absolute path for pathSegments: C:\Program Files\Git\bin/docker = C:\Program Files\Git\bin\docker
##[debug]Absolute path for pathSegments: C:\Program Files\Git\usr\bin/docker = C:\Program Files\Git\usr\bin\docker
##[debug]Absolute path for pathSegments: C:\Program Files\Git\mingw64\bin/docker = C:\Program Files\Git\mingw64\bin\docker
##[debug]Absolute path for pathSegments: C:\hostedtoolcache\windows\Python\3.7.2\Scripts/docker = C:\hostedtoolcache\windows\Python\3.7.2\Scripts\docker
##[debug]Absolute path for pathSegments: C:\hostedtoolcache\windows\Python\3.7.2/docker = C:\hostedtoolcache\windows\Python\3.7.2\docker
##[debug]Absolute path for pathSegments: C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin/docker = C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\docker
##[debug]Absolute path for pathSegments: C:\windows\system32/docker = C:\windows\system32\docker
##[debug]Absolute path for pathSegments: C:\windows/docker = C:\windows\docker
##[debug]Absolute path for pathSegments: C:\windows\System32\Wbem/docker = C:\windows\System32\Wbem\docker
##[debug]Absolute path for pathSegments: C:\windows\System32\WindowsPowerShell\v1.0\/docker = C:\windows\System32\WindowsPowerShell\v1.0\docker
##[debug]Absolute path for pathSegments: C:\windows\System32\OpenSSH\/docker = C:\windows\System32\OpenSSH\docker
##[debug]Absolute path for pathSegments: C:\ProgramData\Chocolatey\bin/docker = C:\ProgramData\Chocolatey\bin\docker
##[debug]Absolute path for pathSegments: C:\Program Files\Docker/docker = C:\Program Files\Docker\docker
##[debug]check path : C:\Program Files\Docker\docker.exe
##[debug]docker=C:\Program Files\Docker\docker.exe
##[debug]dockerHostEndpoint=null
##[debug]DOCKER_CONFIG=undefined
##[debug]Processed: ##vso[task.setvariable variable=CONTAINER_AUTHENTICATIONTOKEN;issecret=true;]***
##[debug]agent.tempDirectory=d:\a\_temp
##[debug]testing directory 'd:\a\_temp\DockerConfig_1556703843570\trust\private'
##[debug]testing directory 'd:\a\_temp\DockerConfig_1556703843570\trust'
##[debug]testing directory 'd:\a\_temp\DockerConfig_1556703843570'
##[debug]mkdir 'd:\a\_temp\DockerConfig_1556703843570\trust'
##[debug]mkdir 'd:\a\_temp\DockerConfig_1556703843570\trust\private'
##[debug]Writing Docker config to temp file. File path: d:\a\_temp\DockerConfig_1556703843570\config.json, Docker config: {"auths": { "moderndotnet.azurecr.io": {"auth": "***", "email": "ServicePrincipal@AzureRM" } }, "HttpHeaders":{"X-Meta-Source-Client":"VSTS"} }
##[debug]Synced the file content to the disk. The content is {"auths": { "moderndotnet.azurecr.io": {"auth": "***", "email": "ServicePrincipal@AzureRM" } }, "HttpHeaders":{"X-Meta-Source-Client":"VSTS"} }.
##[debug]action=Build an image
##[debug]Processed: ##vso[telemetry.publish area=TaskEndpointId;feature=DockerV0]{"registryType":"Azure Container Registry","command":"build an image"}
##[debug]C:\Program Files\Docker\docker.exe arg: build
##[debug]dockerFile=d:\a\1\s\WebApplication1\Dockerfile
##[debug]No pattern found in docker filepath parameter
##[debug]C:\Program Files\Docker\docker.exe arg: ["-f","d:\\a\\1\\s\\WebApplication1\\Dockerfile"]
##[debug]buildArguments=null
##[debug]enforceDockerNamingConvention=true
##[debug]imageName=ModernDotNet3:239
##[debug]qualifyImageName=true
##[debug]enforceDockerNamingConvention=true
##[debug]C:\Program Files\Docker\docker.exe arg: ["-t","moderndotnet.azurecr.io/moderndotnet3:239"]
##[debug]additionalImageTags=null
##[debug]includeSourceTags=false
##[debug]includeLatestTag=true
##[debug]C:\Program Files\Docker\docker.exe arg: ["-t","moderndotnet.azurecr.io/moderndotnet3"]
##[debug]memory=null
##[debug]defaultContext=true
##[debug]C:\Program Files\Docker\docker.exe arg: d:\a\1\s\WebApplication1
##[debug]exec tool: C:\Program Files\Docker\docker.exe
##[debug]Arguments:
##[debug]   build
##[debug]   -f
##[debug]   d:\a\1\s\WebApplication1\Dockerfile
##[debug]   -t
##[debug]   moderndotnet.azurecr.io/moderndotnet3:239
##[debug]   -t
##[debug]   moderndotnet.azurecr.io/moderndotnet3
##[debug]   d:\a\1\s\WebApplication1
[command]"C:\Program Files\Docker\docker.exe" build -f d:\a\1\s\WebApplication1\Dockerfile -t moderndotnet.azurecr.io/moderndotnet3:239 -t moderndotnet.azurecr.io/moderndotnet3 d:\a\1\s\WebApplication1
Sending build context to Docker daemon  3.072kB

Step 1/4 : FROM microsoft/aspnet@sha256:51fdd2a971dcc07d670da477a2f0d6d3c0a6872ea3f0f89226b98b62ccb1c2a1
 ---> 4bc43f167268
Step 2/4 : ARG source
 ---> Running in b8a1d08f87ae
Removing intermediate container b8a1d08f87ae
 ---> d6e0eddc5570
Step 3/4 : WORKDIR /inetpub/wwwroot
 ---> Running in 0dec2d9301a4
Removing intermediate container 0dec2d9301a4
 ---> b4b5186e134b
Step 4/4 : COPY ./. .
 ---> 385f0a3f9fb8
Successfully built 385f0a3f9fb8
Successfully tagged moderndotnet.azurecr.io/moderndotnet3:239
Successfully tagged moderndotnet.azurecr.io/moderndotnet3:latest
##[debug]rc:0
##[debug]success:true
##[debug]set DockerOutput=
##[debug]Processed: ##vso[task.setvariable variable=DockerOutput;secret=false;]
##[debug]task result: Succeeded
##[debug]Processed: ##vso[task.complete result=Succeeded;]
##[section]Finishing: Build an image
奇怪的是这句话:

Sending build context to Docker daemon  3.072kB
docker build命令仅向docker守护程序发送了3.072kB。这是不可能的。MSBuild之后的项目大小应至少为52MB。由于构建代理说它刚刚将3.072kB发送到Docker守护进程,所以我无法将任何文件复制到映像中


我尝试在我的Windows10(1809)本地计算机上使用完全相同的命令。根本没有问题。问题只存在于Azure管道上。我不知道怎么修理它。有人能帮忙吗?

在Visual Studio 2019中创建具有Docker支持的ASP.NET MVC(.NET Framework)项目时,该项目将添加一个默认的
.DockerInore
文件,其中包含以下内容:

*
!obj\Docker\publish\*
!obj\Docker\empty\
经过几个小时的战斗,我终于看到了文件中的第一行。它是
.dockrignore
文件中的一颗星星。它只是在做docker构建时忽略了一切。一开始我没料到。