Reputation: 21
Cannot build the docker image in the cicd , the path to the image is not found.
here is my dockerfile
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-ltsc2019
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-./obj/Docker/publish} .
#I am choising Azure pipeline agent windows-2019
Step 4/4 : COPY ${source:-./obj/Docker/publish} .
COPY failed: CreateFile \?\C:\ProgramData\docker\tmp\docker-builder174212468\obj\Docker\publish: The system cannot find the path specified. [error]C:\Program Files\Docker\docker.exe failed with return code: 1
Upvotes: 2
Views: 1885
Reputation: 6658
I had the same issue and finally solved it. I'm using the new YAML pipeline with " Docker@2" Task. The solution was to specify the "buildContext" property. I must be the same as the WorkingDir in your Dockerfile.
Dockerfile:
WORKDIR /src
Azure Pipeline Yaml:
buildContext: 'src/'
Full task:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: '$(imageRepository)'
command: 'buildAndPush'
Dockerfile: 'src/Dockerfile'
buildContext: 'src/'
tags: '$(tag)'
Upvotes: 2
Reputation: 59946
The error is very clear COPY
can not find the file you are trying to copy during the build.
$source
variable refers to the current directory. If $source is empty or absent, just use the default path obj/Docker/publish
.
You can check this issue (Is it possible to change default directory (obj/docker/publish) to copy files) on Github or issues-6.
When building the image it copies the content from the path specified in the source argument to the current directory within the container. If there is no source argument specified, the contents from the path obj/Docker/publish are used.
understanding-docker-with-visual-studio
Upvotes: 0