1

I'm try to publish a docker container in AWS ECR/ECS using an Azure Devops Pipeline. so what do I do:

  1. I created an asp.NET WebApi project (not core)
  2. I added the dockerfile from Visual Studio 2019 (I haven't changed the default file)
  3. I pushed to a repos in azure devops
  4. I created a build pipeline for building the solution
  5. I added a docker build operation to the pipeline
  6. Try to Push Image to AWS ECR

The result is that until the solution build everything is working, but when I try to build the docker I have a Copy error (this is the log):

Starting: build
================================================== ============================
Task: Docker
Description: Build or push Docker images, login or logout, or run a Docker command
Version: 2.162.0
Author: Microsoft Corporation
Help: https://learn.microsoft.com/azure/devops/pipelines/tasks/build/docker
================================================== ============================
"C: \ Program Files \ Docker \ docker.exe" build -fd: \ a \ 2 \ s \ xxx\ xxx\ Dockerfile --label com.azure.dev.image.system.teamfoundationcollectionuri = https: // dev. azure.com/yyy/ --label com.azure.dev.image.system.teamproject = InRule --label com.azure.dev.image.build.repository.name = xxx-backend --label com.azure.dev .image.build.sourceversion = 3580bfefbe0592212a1d9c76c6d30dd472e22748 --label com.azure.dev.image.build.repository.uri = https: //[email protected]/xxx/xxx/_git/xxx-backend .azure.dev.image.build.sourcebranchname = develop --label "com.azure.dev.image.build.definitionname = In WebApi Release Docker rule" --label com.azure.dev.image.build.buildnumber = 20200204.12 - -label com.azure.dev.image.build.builduri = vstfs: /// Build / Build / 11456 -t xxx d: \ a \ 2 \ s \ yyy\ yyy
Sending build context to Docker daemon 3.072kB

Step 1/13: FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
 ---> a5bc996f06b3
Step 2/13: ARG source
 ---> Running in f385f2f0cc47
Removing intermediate container f385f2f0cc47
 ---> 525c70129725
Step 3/13: WORKDIR / inetpub / wwwroot
 ---> Running in a8b464b080f2
Removing intermediate container a8b464b080f2
 ---> 534984f17fd7
Step 4/13: COPY $ {source: -obj / Docker / publish}.
COPY failed: CreateFile \\? \ C: \ ProgramData \ docker \ tmp \ docker-builder949209785 \ obj \ Docker \ publish: The system cannot find the path specified.
## [error] The process 'C: \ Program Files \ Docker \ docker.exe' failed with exit code 1
Finishing: build

My pipeline YAML code is:

pool:
  name: Azure Pipelines
  demands:
  - msbuild
  - visualstudio

steps:
- task: NuGetToolInstaller @ 0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1

- task: NuGetCommand @ 2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: XXXSolution.sln

- task: VSBuild @ 1
  displayName: 'Build solution'
  inputs:
    solution: XXXSolution.sln
    msbuildArgs: '/ p: DeployOnBuild = true / p: WebPublishMethod = Package / p: PackageAsSingleFile = true / p: SkipInvalidConfigurations = true / p: PackageLocation = "$ (build.artifactstagingdirectory) \\"'
    platform: '$ (BuildPlatform)'
    configuration: '$ (BuildConfiguration)'

- task: PublishBuildArtifacts @ 1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$ (build.artifactstagingdirectory)'
    ArtifactName: '$ (Parameters.ArtifactName)'
  enabled: false
  condition: succeededOrFailed ()

- task: ExtractFiles @ 1
  displayName: 'Extract files'
  inputs:
    archiveFilePatterns: '$ (build.artifactstagingdirectory) /XXX.zip'
    destinationFolder: '$ (build.artifactstagingdirectory) / XXX / XXX / obj / Docker / publish'

- task: Docker @ 2
  displayName: build
  inputs:
    command: build
    Dockerfile: XXX / XXX / Dockerfile
    arguments: '-t XXX'

- task: CopyFiles @ 2
  displayName: 'Copy Files to: $ (build.artifactstagingdirectory) / obj / Docker / publish'
  inputs:
    SourceFolder: '$ (build.artifactstagingdirectory)'
    TargetFolder: '$ (build.artifactstagingdirectory) / obj / Docker / publish'
  enabled: false

- task: AmazonWebServices.aws-vsts-tools.ECRPushImage.ECRPushImage@1
  displayName: 'Push Image:'
  inputs:
    awsCredentials: awsCredentials
    regionName: 'eu-west-1'
    sourceImageName: XXX
    repositoryName: XXX

- task: PublishSymbols @ 2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '** \ bin \ ** \ *. Pdb'
    PublishSymbols: false
  enabled: false
  continueOnError: true

Can anyone help me to understand where the error is?

2
  • Hi ActiveDev, how about this issue, have you figured out it? Commented Feb 19, 2020 at 9:12
  • Hi ActiveDev, any update on this issue, Did you get a chance to implement the solution that Alexandre Nourissier suggested? Were you able to resolve? Commented Mar 3, 2020 at 10:47

2 Answers 2

1

I think your tasks "Docker@2" and "CopyFiles@2" are inverted.

If you look at the docker log, you can see that Docker expects to find the publish output inside a \obj\Docker\publish folder but you only copy them there after the Docker@2.

Sign up to request clarification or add additional context in comments.

Comments

0

This is the new log after change the order of the tasks:

2020-02-07T10:45:04.4589916Z ##[section]Starting: build
2020-02-07T10:45:04.4701538Z ==============================================================================
2020-02-07T10:45:04.4701659Z Task         : Docker
2020-02-07T10:45:04.4701727Z Description  : Build or push Docker images, login or logout, or run a Docker command
2020-02-07T10:45:04.4701805Z Version      : 2.162.0
2020-02-07T10:45:04.4701860Z Author       : Microsoft Corporation
2020-02-07T10:45:04.4701927Z Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/docker
2020-02-07T10:45:04.4702016Z ==============================================================================
2020-02-07T10:45:04.8198317Z [command]"C:\Program Files\Docker\docker.exe" build -f D:\a\1\s\XXX\XXX\Dockerfile --label com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/XXX/ --label com.azure.dev.image.system.teamproject=XXX --label com.azure.dev.image.build.repository.name=XXX-backend --label com.azure.dev.image.build.sourceversion=3580bfefbe0592212a1d9c76c6d30dd472e22748 --label com.azure.dev.image.build.repository.uri=https://[email protected]/XXX/XXX/_git/XXX-backend --label com.azure.dev.image.build.sourcebranchname=develop --label "com.azure.dev.image.build.definitionname=XXX WebApi Release Docker" --label com.azure.dev.image.build.buildnumber=20200207.1 --label com.azure.dev.image.build.builduri=vstfs:///Build/Build/11467 -t XXX D:\a\1\s\XXX\XXX
2020-02-07T10:45:11.7158942Z Sending build context to Docker daemon  3.072kB
2020-02-07T10:45:11.7159461Z 
2020-02-07T10:45:11.7600295Z Step 1/13 : FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
2020-02-07T10:45:11.7698947Z  ---> a5bc996f06b3
2020-02-07T10:45:11.7699194Z Step 2/13 : ARG source
2020-02-07T10:45:12.2010655Z  ---> Running in e5d56a7c6647
2020-02-07T10:45:14.4009801Z Removing intermediate container e5d56a7c6647
2020-02-07T10:45:14.4010663Z  ---> 298dd53c140a
2020-02-07T10:45:14.4011018Z Step 3/13 : WORKDIR /inetpub/wwwroot
2020-02-07T10:45:14.4463513Z  ---> Running in e44696a950d4
2020-02-07T10:45:15.9378724Z Removing intermediate container e44696a950d4
2020-02-07T10:45:15.9379138Z  ---> e6e8d9c8ab53
2020-02-07T10:45:15.9380224Z Step 4/13 : COPY ${source:-obj/Docker/publish} .
2020-02-07T10:45:15.9380626Z COPY failed: CreateFile \\?\C:\ProgramData\docker\tmp\docker-builder901134993\obj\Docker\publish: The system cannot find the path specified.
2020-02-07T10:45:15.9467650Z ##[error]The process 'C:\Program Files\Docker\docker.exe' failed with exit code 1
2020-02-07T10:45:15.9528776Z ##[section]Finishing: build

1 Comment

As I said, "Docker expects to find the publish output inside a \obj\Docker\publish folder" but your copy step in the docker file doesn't point to the right folder. You need to change the argument of step 4.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.