I have a simple out of the box VS2017 web api that I am trying to build a Docker Image for on VSTS and publish the image to Azure container registry. But its not working, error below:
2018-05-21T16:49:45.8481201Z Step 7/17 : COPY WebApi/WebApi.csproj WebApi/
2018-05-21T16:49:45.8503445Z COPY failed: stat /var/lib/docker/tmp/docker-builder936381234/WebApi/WebApi.csproj: no such file or directory
2018-05-21T16:49:45.8644972Z ##[error]COPY failed: stat /var/lib/docker/tmp/docker-builder936381234/WebApi/WebApi.csproj: no such file or directory
2018-05-21T16:49:45.8732546Z ##[error]/usr/local/bin/docker failed with return code: 1
Its a standard VS2017 solution.
Dockerfile
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 63537
EXPOSE 44369
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY WebApi/WebApi.csproj WebApi/
RUN dotnet restore WebApi/WebApi.csproj
COPY . .
WORKDIR /src/WebApi
RUN dotnet build WebApi.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish WebApi.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "WebApi.dll"]
.dockerignore
.dockerignore
.env
.git
.gitignore
.vs
.vscode
docker-compose.yml
docker-compose.*.yml
*/bin
*/obj
docker-compose.yml
version: '3.4'
services:
webapi:
image: webapi
build:
context: .
dockerfile: WebApi/Dockerfile
I have tried all the suggested solutions by changing the .dockerignore file, deleting it etc etc.
COPY WebApi/WebApi.csproj WebApi/
fails asWebApi/WebApi.csproj
does not exist, so check why – user2915097docker build
command. Docker will take a snapshot of this folder (and all subfolders) and forward it to the docker deamon to process. I.e. your paths in the dockerfile must be relative to where you call thedocker build
command. – Efrain