How to Run Jenkins slaves on Docker
Posted By : Jatin Gupta | 30-Jul-2018
Jenkins is most well known an open source automation server written in Java. It has numerous fascinating modules and highlights. Today, I will demonstrate you one of them – how to set up Jenkins master server with one slave associated with it. With the goal that we will have the capacity to run distributed builds using few containers. For that example we utilize docker images of (jenkins) and Jenkins slave (jenkinsci/jnlp-slave). How about we begin from running Jenkins docker container.
docker run -dit --name jenkins -p 8080:8080 -p 50000:50000 jenkins
Go to jenkins console (http://localhost:8080) and select Manage Jenkins - > Manage Nodes and after that select New Node.
In the following page you need to put the slave name – for that example is slave1.
Subsequent to clicking OK you will see new node on the rundown. Presently, you can configure it by clicking setting tab.
The important data is in command secret. Save that token.
docker run -dit --name jenkins-slave1 jenkinsci/jnlp-slave -url http://localhost:8080 250f30e4d2753263312b4fa3d3ca560cba02b010479874316901ed03a6df0660 slave1
After starting slave docker you can see name slave1 in the Build Executor Status beneath master node.
We can also run stages on this node using pipeline as code,
node('slave-1') {
stage('Checkout') {
...
}
stage('Build') {
...
}
}
This will run both the stages on node "slave1" rather than running them on master node.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Jatin Gupta
Jatin is a DevOps trainee. He ha deep interest in python and cloud technologies. He likes to read about science/history and fiction, listening to music and explore new places.