You may have a project that is using Docker, but built using Jenkins - it is becoming increasingly popular to have a Dockerfile that describes how to build your project.
Alternatively - you may want to build an image, export it, push it somewhere.
Both of these require you to have a build executor that is running Docker. Docker currently requires elevated privileges to run Docker builds - making it a challenge (at the moment) for multi-tenant environments.
But fear not - you can use this with DEV@cloud via On-prem-executors. This lets you connect any server to your DEV@cloud service - so it can participate in builds - in this case providing Docker.
Initial setup
Ensure you are subscribed to a plan that allows On-prem-executors
Pick and launch server and install docker and java onto (Amazon AMIs are ok here).
Download the jenkins-cli.jar as specified from your Jenkins server on to your executor server
Check docker is running (docker version ) on your executor server
run ssh-keygen on your Jenkins executor server - copy the public key and add it to your CloudBees user (so that this server can connect )
check you can connect to your controller with the private key using a command like
java -jar jenkins-cli.jar -s https://.ci.cloudbees.com on-premise-executor -fsroot /root/workspace -labels docker -name docker-builder-1
once you have that working - cancel the command - and set it up via a systemd daemon (see here ).
Using Docker in your DEV@cloud builds
This is very simple once you have done the above: Change your job configuration to say "docker":
You only need to do this in builds that will need to run Docker.
Running the build agent on linux
Linux is now pretty much standardising on systemd for running daemons. As you want to have your agent always running - and if it crashes - restart it - systemd is great (the agent may crash for many reasons - but also if your DEV@cloud controller is restarted - so you do want to do this):
The script is here (based on one I used) put the following a file called ope.service:
[Unit]
Description=CloudBeees On Prem executor
Documentation= developer.cloudbees.com/bin/view/DEV/On-Premise+Executors
Requires=network.target
After=multi-user.target
[Service]
Type=simple
ExecStart=/opt/java6/bin/java -jar /root/jenkins-cli.jar -s https://cloudbees.ci.cloudbees.com on-premise-executor -fsroot /root/workspace -labels docker -nam\
e docker-builder-1
Restart=always
[Install]
WantedBy=multi-user.target
Adjust it to use the paths you want, then run:
install -D -m 644 ope.service /usr/lib/systemd/system/ope.service
systemctl daemon-reload
systemctl start ope # launch the service
systemctl enable ope # ensure it restarts if whole server is restarted
We hope to offer Docker build on DEV@cloud agents one day - but for now - you can use OPE to get a docker build as part of your pipeline if you need it.