I have a jenkins container and a pipeline which consist of building docker images. I have mounted the necessary mounts (/var/run/docker.sock, /var/run) for jenkins to use docker commands. I also bind mounted a folder from my host to jenkins as its workspace directory (/var/jenkins_home/workspace).

Here is the Dockerfile which is part of my project:

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base

 FROM microsoft/dotnet:2.1-sdk AS build
 RUN hostname && pwd
 COPY /storage/admin/jenkins/workspace/tremplinx_master-NAUVRHOZ5IJBBHVQ54PTEZJJL33WO7NMFUYS5BF3C5H3LBCDC3XA/SPA/SPA.csproj SPA/SPA.csproj
 RUN dotnet restore SPA/SPA.csproj
 COPY . .
 RUN dotnet build SPA.csproj -c Release -o /app

Running my pipeline fail with the following error:

[tremplinx_master-NAUVRHOZ5IJBBHVQ54PTEZJJL33WO7NMFUYS5BF3C5H3LBCDC3XA] Running shell script

+ docker build -t spa:dev-0.0.1 SPA/

Sending build context to Docker daemon  4.536MB

Step 1/17 : FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base

 ---> 625b44243fbe

Step 2/17 : WORKDIR /app

 ---> Using cache

 ---> 8279155deb77

Step 3/17 : EXPOSE 80

 ---> Using cache

 ---> 574345928687

Step 4/17 : FROM microsoft/dotnet:2.1-sdk AS build

 ---> f6d6062f4612

Step 5/17 : WORKDIR /src

 ---> Using cache

 ---> b49549e644ac

Step 6/17 : COPY /storage/admin/jenkins/workspace/tremplinx_master-NAUVRHOZ5IJBBHVQ54PTEZJJL33WO7NMFUYS5BF3C5H3LBCDC3XA/SPA/SPA.csproj SPA/SPA.csproj

COPY failed: stat /var/lib/docker/tmp/docker-builder969545350/storage/admin/jenkins/workspace/tremplinx_master-NAUVRHOZ5IJBBHVQ54PTEZJJL33WO7NMFUYS5BF3C5H3LBCDC3XA/SPA/SPA.csproj: no such file or directory

script returned exit code 1

I can't figure out why docker is using /var/lib/docker/tmp/docker-builder969545350... folder whereas I have specified the full path containing my project. I'm new to Jenkins so forgive me if I forgot to specify important information .

Thank you.


I've solved my issue. I had to change the way I call my Dockerfile and changing the WORKDIR inside.

  • Can you be more specific with the resolution? I have the same issue. – Vadim May 11 '20 at 13:27
  • Files and directories from the COPY step should be within the build context. From the Dockerfile reference/COPY section : "The <src> path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon." – cyrilv May 13 '20 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.