Skip to content

Latest commit

 

History

History
26 lines (23 loc) · 1.92 KB

configure-docker-agents.md

File metadata and controls

26 lines (23 loc) · 1.92 KB

Configure Docker Agents

An agent is typically a machine, or container, which connects to a Jenkins master and executes tasks when directed by the master. From: Jenkins Docs

After Setting up Jenkins, follow the next steps to configure new agents.

  1. Go to Jenkins > Manage Jenkins > Configure System > Cloud > Docker Agent templates.
  2. Type the Label that will be used to match the agents of your Jenkinsfile.
  3. Select the Enabled option.
  4. Type the name followed by the version of the image that will be initiated by a docker container managed by the Jenkins Master, ex: jenkins-slave:1.0.
  5. Press on Volumes button, and add the necessary volumes in order to save all the work done by the containers during the pipelines, ex:
jenkins_jenkins-slave-home:/home/jenkins:rw
/var/run/docker.sock:/var/run/docker.sock:rw
/home/ubuntu/.ssh:/home/jenkins/.ssh:rw

Note: Look at the importance of mounting the /var/run/docker.sock volume. It's necessary to mount the socket that communicates with the docker deamon to the slave containers, due to the fact that inside the slaves, we'll have the need to build images or use some docker commands. Otherwise, we could have difficulties running docker-in-docker as this article exposes.

  1. Add the network name so that the slave can see jenkins master on /proxy1 jenkins_jenkins-net.
  2. On Remote Filing System Root type: /home/jenkins.
  3. On Usage select, 'Only build jobs with label expressions matching this node'.
  4. On Idle timeout, type: 10
  5. On Connect method select: 'Attach Docker container'. A new option will pop-up, then type User: Jenkins
  6. On Pull strategy select: 'Never pull'
  7. On Pull timeout, type: 300
  8. Finally, click on Apply and then Save your job.