in Jenkinsfile below, agent docker
is used https://www.jenkins.io/doc/book/pipeline/docker/
But which slave is used, can I point to the VM I want to run docker?
pipeline {
agent {
docker { image 'node:14-alpine' }
}
stages {
stage('Test') {
steps {
sh 'node --version'
}
}
}
}
Something like
agent {
label "dockerserver"
docker { image 'node:14-alpine' }
}
Jenkins assumes any configured agent can run docker containers. This is documented here: https://www.jenkins.io/doc/book/pipeline/docker/#specifying-a-docker-label
A label can be configured in the System Configuration to select which agents can run containers:
Pipeline provides a global option in the Manage Jenkins page, and on the Folder level, for specifying which agents (by Label) to use for running Docker-based Pipelines.
Attach the label to the agents which should run docker containers.
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.