The goal is to push an image to dockerhub, which works great from the Visual Studio "Publish" feature.
I have this Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj", "DockerTestWebsiteLinux/"]
RUN dotnet restore "DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj"
COPY . .
WORKDIR "/src/DockerTestWebsiteLinux"
RUN dotnet build "DockerTestWebsiteLinux.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "DockerTestWebsiteLinux.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "DockerTestWebsiteLinux.dll"]
which is the default one for a blank ASP.NET Core project generated with VS2019, newest version.
The pipeline YAML looks like this:
steps:
- task: Docker@0
displayName: 'Build an image'
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryConnection: 'docker hub jc'
dockerFile: DockerTestWebsiteLinux/Dockerfile
(Thats the default one that comes up when you click "Docker" as job, i only changed the path to the dockerfile, since its one project out of many in a solution)
He seems to find the Dockerfile just fine, but then exists with
Step 6/16 : COPY ["DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj", "DockerTestWebsiteLinux/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder071437444/DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj: no such file or directory
##[error]COPY failed: stat /var/lib/docker/tmp/docker-builder071437444/DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj: no such file or directory
##[error]/usr/bin/docker failed with return code: 1
What do i do wrong?
The Full Log is:
2020-06-12T11:19:12.4891643Z ##[section]Starting: Build an image
2020-06-12T11:19:12.4903893Z ==============================================================================
2020-06-12T11:19:12.4904229Z Task : Docker
2020-06-12T11:19:12.4904567Z Description : Build, tag, push, or run Docker images, or run a Docker command
2020-06-12T11:19:12.4904871Z Version : 0.157.2
2020-06-12T11:19:12.4905150Z Author : Microsoft Corporation
2020-06-12T11:19:12.4905502Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/docker
2020-06-12T11:19:12.4905906Z ==============================================================================
2020-06-12T11:19:12.9134260Z c99ab064-584c-4340-b58e-7a19ca76f6b8 exists true
2020-06-12T11:19:12.9842066Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9842743Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9843349Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9843985Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9844543Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9845090Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9845644Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9846187Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9846740Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9847280Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9847830Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9848370Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9848914Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9849468Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9850017Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9850568Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9851111Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9851662Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9852200Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9852750Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9853292Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9853843Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9854385Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9855199Z (node:3877) Warning: Use Cipheriv for counter mode of aes-256-ctr
2020-06-12T11:19:12.9859182Z [command]/usr/bin/docker build -f /home/vsts/work/9/s/DockerTestWebsiteLinux/Dockerfile -t mlatwork:256 /home/vsts/work/9/s/DockerTestWebsiteLinux
2020-06-12T11:19:13.4004892Z Sending build context to Docker daemon 11.78kB
2020-06-12T11:19:13.4005606Z
2020-06-12T11:19:13.4565372Z Step 1/16 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
2020-06-12T11:19:13.6021599Z 3.1-buster-slim: Pulling from dotnet/core/aspnet
2020-06-12T11:19:13.6038540Z 8559a31e96f4: Pulling fs layer
2020-06-12T11:19:13.6044182Z dc08029e21f9: Pulling fs layer
2020-06-12T11:19:13.6044508Z 734d0e250adf: Pulling fs layer
2020-06-12T11:19:13.6044768Z 84249fbd30d6: Pulling fs layer
2020-06-12T11:19:13.6045041Z 84d07bfbfd3f: Pulling fs layer
2020-06-12T11:19:13.6045286Z 84249fbd30d6: Waiting
2020-06-12T11:19:13.6045529Z 84d07bfbfd3f: Waiting
2020-06-12T11:19:13.6905803Z 734d0e250adf: Download complete
2020-06-12T11:19:13.8902364Z dc08029e21f9: Verifying Checksum
2020-06-12T11:19:13.8904333Z dc08029e21f9: Download complete
2020-06-12T11:19:13.9788197Z 8559a31e96f4: Verifying Checksum
2020-06-12T11:19:13.9793870Z 8559a31e96f4: Download complete
2020-06-12T11:19:14.0424733Z 84249fbd30d6: Verifying Checksum
2020-06-12T11:19:14.0429176Z 84249fbd30d6: Download complete
2020-06-12T11:19:14.0836902Z 84d07bfbfd3f: Verifying Checksum
2020-06-12T11:19:14.0846946Z 84d07bfbfd3f: Download complete
2020-06-12T11:19:15.1361383Z 8559a31e96f4: Pull complete
2020-06-12T11:19:15.7092876Z dc08029e21f9: Pull complete
2020-06-12T11:19:15.8149265Z 734d0e250adf: Pull complete
2020-06-12T11:19:16.5138806Z 84249fbd30d6: Pull complete
2020-06-12T11:19:16.7693218Z 84d07bfbfd3f: Pull complete
2020-06-12T11:19:16.7722239Z Digest: sha256:b5ca2387bc65608bed936c04f40ddd92e8b6a5a3387f38a210e18d531080f2ca
2020-06-12T11:19:16.7751385Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim
2020-06-12T11:19:16.7759194Z ---> 7e3fe71c7693
2020-06-12T11:19:16.7759605Z Step 2/16 : WORKDIR /app
2020-06-12T11:19:20.0241824Z ---> Running in 5f40e0c57f8f
2020-06-12T11:19:21.0254992Z Removing intermediate container 5f40e0c57f8f
2020-06-12T11:19:21.0256309Z ---> 781ae87ed64e
2020-06-12T11:19:21.0256726Z Step 3/16 : EXPOSE 80
2020-06-12T11:19:21.0753001Z ---> Running in f63a9f7f81a0
2020-06-12T11:19:22.0301005Z Removing intermediate container f63a9f7f81a0
2020-06-12T11:19:22.0302213Z ---> 7a89f78b321c
2020-06-12T11:19:22.0302737Z Step 4/16 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
2020-06-12T11:19:22.1082117Z 3.1-buster: Pulling from dotnet/core/sdk
2020-06-12T11:19:22.1082686Z e9afc4f90ab0: Pulling fs layer
2020-06-12T11:19:22.1083039Z 989e6b19a265: Pulling fs layer
2020-06-12T11:19:22.1083406Z af14b6c2f878: Pulling fs layer
2020-06-12T11:19:22.1083748Z 5573c4b30949: Pulling fs layer
2020-06-12T11:19:22.1084108Z 17f039feca24: Pulling fs layer
2020-06-12T11:19:22.1084451Z a739c871edc6: Pulling fs layer
2020-06-12T11:19:22.1084919Z 8d7e6a1ea13e: Pulling fs layer
2020-06-12T11:19:22.1085152Z 17f039feca24: Waiting
2020-06-12T11:19:22.1085370Z a739c871edc6: Waiting
2020-06-12T11:19:22.1085614Z 8d7e6a1ea13e: Waiting
2020-06-12T11:19:22.1085832Z 5573c4b30949: Waiting
2020-06-12T11:19:22.2752636Z 989e6b19a265: Verifying Checksum
2020-06-12T11:19:22.2753050Z 989e6b19a265: Download complete
2020-06-12T11:19:22.2890385Z af14b6c2f878: Verifying Checksum
2020-06-12T11:19:22.2890748Z af14b6c2f878: Download complete
2020-06-12T11:19:22.4478115Z 17f039feca24: Verifying Checksum
2020-06-12T11:19:22.4478471Z 17f039feca24: Download complete
2020-06-12T11:19:22.7472123Z e9afc4f90ab0: Verifying Checksum
2020-06-12T11:19:22.7472472Z e9afc4f90ab0: Download complete
2020-06-12T11:19:22.9057708Z 5573c4b30949: Verifying Checksum
2020-06-12T11:19:22.9059825Z 5573c4b30949: Download complete
2020-06-12T11:19:23.0119160Z 8d7e6a1ea13e: Verifying Checksum
2020-06-12T11:19:23.0120321Z 8d7e6a1ea13e: Download complete
2020-06-12T11:19:23.7463177Z a739c871edc6: Verifying Checksum
2020-06-12T11:19:23.7464827Z a739c871edc6: Download complete
2020-06-12T11:19:24.9514807Z e9afc4f90ab0: Pull complete
2020-06-12T11:19:25.2664959Z 989e6b19a265: Pull complete
2020-06-12T11:19:25.5500940Z af14b6c2f878: Pull complete
2020-06-12T11:19:27.5001594Z 5573c4b30949: Pull complete
2020-06-12T11:19:27.8404155Z 17f039feca24: Pull complete
2020-06-12T11:19:31.4556340Z a739c871edc6: Pull complete
2020-06-12T11:19:31.9511844Z 8d7e6a1ea13e: Pull complete
2020-06-12T11:19:31.9534709Z Digest: sha256:1616a64f2eb95e1d9bc0f7185cff16aa44ce0f63c8f61d6bebac5f810d580711
2020-06-12T11:19:31.9550718Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1-buster
2020-06-12T11:19:31.9558815Z ---> 5f369f0d8192
2020-06-12T11:19:31.9559092Z Step 5/16 : WORKDIR /src
2020-06-12T11:19:40.3165947Z ---> Running in 9d104c6e7d2b
2020-06-12T11:19:41.0594271Z Removing intermediate container 9d104c6e7d2b
2020-06-12T11:19:41.0595329Z ---> d49cec115c36
2020-06-12T11:19:41.0595671Z Step 6/16 : COPY ["DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj", "DockerTestWebsiteLinux/"]
2020-06-12T11:19:41.0596514Z COPY failed: stat /var/lib/docker/tmp/docker-builder071437444/DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj: no such file or directory
2020-06-12T11:19:41.0645016Z ##[error]COPY failed: stat /var/lib/docker/tmp/docker-builder071437444/DockerTestWebsiteLinux/DockerTestWebsiteLinux.csproj: no such file or directory
2020-06-12T11:19:41.0800905Z ##[error]/usr/bin/docker failed with return code: 1
2020-06-12T11:19:41.0837329Z ##[section]Finishing: Build an image
Edit: i made the problem more reproduceable:
1) Create an empty ASP.NET Core project with Docker support 2) Upload that project into an Azure Devops GIT repo 3) create a pipeline, select "Docker build" as a task
the default pipeline looks like this:
# Docker
# Build a Docker image
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
- repo: self
variables:
tag: '$(Build.BuildId)'
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
displayName: Build an image
inputs:
command: build
dockerfile: '$(Build.SourcesDirectory)/AzureDevopsDockerTest/Dockerfile'
tags: |
$(tag)
But it still exists with:
Step 7/26 : COPY ["AzureDevopsDockerTest/AzureDevopsDockerTest.csproj", "AzureDevopsDockerTest/"]
COPY failed: stat /var/lib/docker/tmp/docker-builder580556181/AzureDevopsDockerTest/AzureDevopsDockerTest.csproj: no such file or directory
##[error]COPY failed: stat /var/lib/docker/tmp/docker-builder580556181/AzureDevopsDockerTest/AzureDevopsDockerTest.csproj: no such file or directory
##[error]The process '/usr/bin/docker' failed with exit code 1
The dockerfile in this particular case:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["AzureDevopsDockerTest/AzureDevopsDockerTest.csproj", "AzureDevopsDockerTest/"]
RUN dotnet restore "AzureDevopsDockerTest/AzureDevopsDockerTest.csproj"
COPY . .
WORKDIR "/src/AzureDevopsDockerTest"
RUN dotnet build "AzureDevopsDockerTest.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "AzureDevopsDockerTest.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AzureDevopsDockerTest.dll"]