1

I am just starting to use Jenkins and Docker in Windows10. Currently I have installed both Jenkins and Docker and created a Dockerfile and a Jenkinsfile

Unfortunately whenever I try to build in Jenkins I keep getting an error. Below is the Jenkin logs

Branch indexing
12:48:47 Connecting to https://api.github.com with no credentials, anonymous access
Obtained Jenkinsfile from 87252353bfae9210f07a234b6af7d17b6aee1363
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\Users\oko\.jenkins\workspace\s-contest_ft-jenkins-integration
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: NONE
No credentials specified
 > git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git.exe config remote.origin.url https://github.com/FurahaSolutions/fs-online-maths-contest.git # timeout=10
Fetching without tags
Fetching upstream changes from https://github.com/FurahaSolutions/fs-online-maths-contest.git
 > git.exe --version # timeout=10
 > git --version # 'git version 2.23.0.windows.1'
 > git.exe fetch --no-tags --force --progress -- https://github.com/FurahaSolutions/fs-online-maths-contest.git +refs/heads/ft-jenkins-integration:refs/remotes/origin/ft-jenkins-integration # timeout=10
Checking out Revision 87252353bfae9210f07a234b6af7d17b6aee1363 (ft-jenkins-integration)
 > git.exe config core.sparsecheckout # timeout=10
 > git.exe checkout -f 87252353bfae9210f07a234b6af7d17b6aee1363 # timeout=10
Commit message: "Added Dockerfile"
 > git.exe rev-list --no-walk 036200096bf00516e0a8b149541ba994efcd360a # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] bat

[m[32m]9;8;"USERNAME"\@]9;8;"COMPUTERNAME"\ [92mC:\Users\oko\.jenkins\workspace\s-contest_ft-jenkins-integration[90m
[90m>[m ]9;12\docker inspect -f . node:latest 
.
[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -d -t -w C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration/ -v C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration/:C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration/ -v C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration@tmp/:C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration@tmp/ -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** node:latest cmd.exe
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: Failed to run image 'node:latest'. Error: docker: Error response from daemon: the working directory 'C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration/' is invalid, it needs to be an absolute path.
See 'docker run --help'.
    at org.jenkinsci.plugins.docker.workflow.client.WindowsDockerClient.run(WindowsDockerClient.java:58)
    at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:198)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:319)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:193)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:126)
    at org.jenkinsci.plugins.docker.workflow.Docker.node(Docker.groovy:66)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:114)
    at org.jenkinsci.plugins.docker.workflow.declarative.DockerPipelineScript.runImage(DockerPipelineScript.groovy:57)
    at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.configureRegistry(AbstractDockerPipelineScript.groovy:73)
    at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.run(AbstractDockerPipelineScript.groovy:51)
    at org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript.checkoutAndRun(CheckoutScript.groovy:61)
    at ___cps.transform___(Native Method)
    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
    at sun.reflect.GeneratedMethodAccessor487.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
    at com.cloudbees.groovy.cps.Next.step(Next.java:83)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
    at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
    at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Finished: FAILUREBranch indexing
12:48:47 Connecting to https://api.github.com with no credentials, anonymous access
Obtained Jenkinsfile from 87252353bfae9210f07a234b6af7d17b6aee1363
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\Users\oko\.jenkins\workspace\s-contest_ft-jenkins-integration
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: NONE
No credentials specified
 > git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git.exe config remote.origin.url https://github.com/FurahaSolutions/fs-online-maths-contest.git # timeout=10
Fetching without tags
Fetching upstream changes from https://github.com/FurahaSolutions/fs-online-maths-contest.git
 > git.exe --version # timeout=10
 > git --version # 'git version 2.23.0.windows.1'
 > git.exe fetch --no-tags --force --progress -- https://github.com/FurahaSolutions/fs-online-maths-contest.git +refs/heads/ft-jenkins-integration:refs/remotes/origin/ft-jenkins-integration # timeout=10
Checking out Revision 87252353bfae9210f07a234b6af7d17b6aee1363 (ft-jenkins-integration)
 > git.exe config core.sparsecheckout # timeout=10
 > git.exe checkout -f 87252353bfae9210f07a234b6af7d17b6aee1363 # timeout=10
Commit message: "Added Dockerfile"
 > git.exe rev-list --no-walk 036200096bf00516e0a8b149541ba994efcd360a # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] bat

[m[32m]9;8;"USERNAME"\@]9;8;"COMPUTERNAME"\ [92mC:\Users\oko\.jenkins\workspace\s-contest_ft-jenkins-integration[90m
[90m>[m ]9;12\docker inspect -f . node:latest 
.
[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -d -t -w C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration/ -v C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration/:C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration/ -v C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration@tmp/:C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration@tmp/ -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** node:latest cmd.exe
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: Failed to run image 'node:latest'. Error: docker: Error response from daemon: the working directory 'C:/Users/oko/.jenkins/workspace/s-contest_ft-jenkins-integration/' is invalid, it needs to be an absolute path.
See 'docker run --help'.
    at org.jenkinsci.plugins.docker.workflow.client.WindowsDockerClient.run(WindowsDockerClient.java:58)
    at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:198)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:319)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:193)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:20)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:126)
    at org.jenkinsci.plugins.docker.workflow.Docker.node(Docker.groovy:66)
    at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(Docker.groovy:114)
    at org.jenkinsci.plugins.docker.workflow.declarative.DockerPipelineScript.runImage(DockerPipelineScript.groovy:57)
    at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.configureRegistry(AbstractDockerPipelineScript.groovy:73)
    at org.jenkinsci.plugins.docker.workflow.declarative.AbstractDockerPipelineScript.run(AbstractDockerPipelineScript.groovy:51)
    at org.jenkinsci.plugins.pipeline.modeldefinition.agent.CheckoutScript.checkoutAndRun(CheckoutScript.groovy:61)
    at ___cps.transform___(Native Method)
    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
    at sun.reflect.GeneratedMethodAccessor487.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
    at com.cloudbees.groovy.cps.Next.step(Next.java:83)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
    at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
    at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
    at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Finished: FAILURE

Dockerfile

# Stage 1

FROM node:10-alpine as build-step

RUN mkdir -p /app

WORKDIR /app

COPY package.json /app

RUN npm install

COPY . /app

RUN npm run build --prod


# Stage 2

FROM nginx:1.17.1-alpine

COPY --from=build-step /app/docs /usr/share/nginx/html

Jenkinsfile

pipeline {
  agent {
    docker { image 'node:latest' }
  }
  stages {
    stage('Install') {
      steps { bat 'npm install' }
    }

    stage('Test') {
      parallel {
        stage('Static code analysis') {
            steps { bat 'npm run-script lint' }
        }
        stage('Unit tests') {
            steps { bat 'npm run-script test' }
        }
      }
    }

    stage('Build') {
      steps { bat 'npm run-script build' }
    }
  }
}

I am building a node application built using Angular

1 Answer 1

2
+50

Your Dockerized Jenkins instance is attempting to use the Docker API to spin up a new Docker container to do your build in. This Docker API it wants to talk to is the same Docker daemon that Jenkins itself is running in.

On a normal Docker daemon running on Linux, you would simply pass in the Docker socket at /var/run/docker.sock as a volume to the Jenkins container (e.g. a -v /var/run/docker.sock:/var/run/docker.sock argument to your docker run command).

However, on Docker for Windows, you are running Docker in a Linux VM on Windows (either by WSL2 or Hyper-V). Depending on how you have your Docker environment setup, you can try to bind the Docker socket in your Jenkins container using one of the following:

  • -v /var/run/docker.sock:/var/run/docker.sock
  • -v //var/run/docker.sock:/var/run/docker.sock
  • -v tcp://127.0.0.1:2376:/var/run/docker.sock

I've seen some solutions do this in addition to one of the above, in order to perform some hacks for Docker for Windows:

  • -v /usr/local/bin/docker:/usr/bin/docker

Or, a better solution that requires less hacks: Do this in a proper Linux OS install. Docker for Windows should not be used in production environments.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .