1
votes

Here is my sample project: https://github.com/doggy8088/AzurePipelinesDockerBuildTest

The Dockerfile only has 3 lines:

FROM microsoft/aspnet@sha256:51fdd2a971dcc07d670da477a2f0d6d3c0a6872ea3f0f89226b98b62ccb1c2a1
WORKDIR /inetpub/wwwroot
COPY . .

I'm using Hosted Windows 2019 with VS2019 as my build agent. When I configured my docker build task, the Queue it. Here are the debug logs:

##[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

The weird part is this line:

Sending build context to Docker daemon  3.072kB

The docker build command only sent 3.072kB to the Docker daemon. It's impossible. The project size after MSBuild should at least 52MB. Due to the build agent said it just sent 3.072kB into Docker daemon, so that I couldn't COPY any files into image.

I try to use the exact same command in my Windows 10 (1809) local machine. There is no problem at all. The problem only exists on Azure Pipelines. I don't know how to fix it. Can anyone help?

1

1 Answers

1
votes

When creating an ASP.NET MVC (.NET Framework) project with Docker support in Visual Studio 2019, the project will add a default .dockerignore file with the following content:

*
!obj\Docker\publish\*
!obj\Docker\empty\

After a few hours of fighting, I finally SEE the first line in this file. IT IS A STAR IN .dockerignore FILE. It just ignored everything when doing a docker build. I didn't expect that at the beginning. 😓