简体   繁体   中英

Using Docker pipeline inside a containerized Jenkins on Docker for Mac

I'm trying to run Jenkins inside of Docker and use the Jenkins Docker Pipeline. I'm using 17.12.0-ce-mac45 (21669) which is the edge edition of Docker. I follow the tutorial on Jenkins's website and run:

docker run \
  --rm \
  -u root \
  -p 8080:8080 \
  -v jenkins-data:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v "$HOME":/home \
 jenkinsci/blueocean

Everything starts up ok but when I try to run just a simple pipeline such as

pipeline {
    agent {
        docker { image 'node:7-alpine' }
    }
    stages {
        stage('Test') {
            steps {
                sh 'node --version'
            }
        }
    }
}

I get an error saying

sh: can't create /var/jenkins_home/workspace@tmp/durable-070664e3/jenkins-log.txt: nonexistent directory
sh: can't create /var/jenkins_home/workspace@tmp/durable-070664e3/jenkins-result.txt: nonexistent directory

Something else comes up before that which says: Jenkins does not seem to be running inside a container

Anyone else run into this problem? When I use docker-machine, it works but just not on Docker for Mac edge. I'm not sure if it works on Docker for Mac stable. My only guess it that the error that comes up saying that Jenkins doesn't seem to think it's in a container is the root of the problem. I did notice in the Github repository on this line that it expects it to look like "/docker/" and that's what makes Jenkins think it's in a container or not. In docker-machine, it looks exactly like that, but on Docker for Mac Edge, it looks like /docker-ce/docker/

我在Docker version 17.12.0-ce, build c97c6d6看到了同样的问题,在macOS上Docker version 17.12.0-ce, build c97c6d6 ,有人已经在Docker version 17.12.0-ce, build c97c6d6 -workflow-plugin https://issues.jenkins-ci.org/browse/中将其报告为错误。 JENKINS-49005 ,现在我使用docker -machine作为一种解决方法,直到对docker-workflow-plugin进行更新或Docker更改cgroup命名。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM