1

i've my windows 10 machine with docker and jenkins for windows and i'm trying to create a jenkins job usign pipelines where i want ro run a build inside a docker container, and for some reason when i start the build it always result in the same following error:

java.io.IOException: Failed to run image 'myimage:tag'. Error: docker: Error response from daemon: the working directory 'D:/jenkins/workspace/jobname@2/' is invalid, it needs to be an absolute path.

before the error occours, i see that is trying to run with the following command automatically

Jenkins does not seem to be running inside a container
$ docker run -d -t -w D:/jenkins/workspace/jobname@2/ -v D:/jenkins/workspace/jobname@2/:D:/jenkins/workspace/jobname@2/ -v D:/jenkins/workspace/jobname@2@tmp/:D:/jenkins/workspace/jobname@2@tmp/ -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ********...

My jenkinsfile is as simple as this

pipeline {
    agent any
    stages {
        stage('Build') {
            agent {
                docker { 
                    image 'myimage:tag'
                }
            }
            steps {
                sh 'ls -lha'
            }
        }
    }
}

What can i do to solve this issue? any ideas?

Flavio CF Oliveira
  • 5,235
  • 13
  • 40
  • 63

1 Answers1

0

Adding to the knowledge base, I am getting a similar result with this hello jenkins.

I get:

Jenkins does not seem to be running inside a container
$ docker run -d -t -w D:/jenkins/home/workspace/p5/ -v D:/jenkins/home/workspace/p5/:D:/jenkins/home/workspace/p5/ -v D:/jenkins/home/workspace/p5@tmp/:D:/jenkins/home/workspace/p5@tmp/

followed by:

"java.io.IOException: Failed to run image 'golang:1.14'. Error: docker: Error response from daemon: the working directory 'D:/jenkins/home/workspace/p5/' is invalid, it needs to be an absolute path.

Relevant link.

Edit 1: this windows and docker looks like it might be a fix. But how to tell what shell docker is running?

Edit 2: This a common problem. This search gets about 1500 hits.

Edit 3: This may be where the problem is.

Ray Tayek
  • 9,841
  • 8
  • 50
  • 90