Running Jenkins as a Docker Container: Difference between revisions
Line 21: | Line 21: | ||
=Networking= | =Networking= | ||
If planning to execute Jenkins with a Docker plugin, create a dedicated [[Docker_Networking_Concepts#User-Defined_Bridge_Networks|user-defined bridge network]] named "jenkins-cloud" and start the Jenkins container so it will connect to that network. This is to take advantage of [[Docker_Networking_Concepts#Automatic_DNS_Resolution_between_Containers |automatic DNS resolution between containers]] when Docker Jenkins agents call into the master: | If planning to execute Jenkins with a Docker plugin, while the Docker server is installed on a laptop with dynamic DHCP address, it may be necessary to start the Docker server in a non-default networking mode. For context, see [[Jenkins_Docker_Plugin#Docker_Hostname_or_IP_address|'Docker Hostname or IP address' configuration section of the Docker Plugin]]. | ||
create a dedicated [[Docker_Networking_Concepts#User-Defined_Bridge_Networks|user-defined bridge network]] named "jenkins-cloud" and start the Jenkins container so it will connect to that network. This is to take advantage of [[Docker_Networking_Concepts#Automatic_DNS_Resolution_between_Containers |automatic DNS resolution between containers]] when Docker Jenkins agents call into the master: | |||
[[Docker_Network_Operations#Create_a_New_User-Defined_Bridge_Network|docker network create]] --driver=bridge jenkins-cloud | [[Docker_Network_Operations#Create_a_New_User-Defined_Bridge_Network|docker network create]] --driver=bridge jenkins-cloud |
Revision as of 20:01, 1 May 2018
Internal
Overview
Image with Pre-Installed Recommended Plugins
The following Dockerfile builds an image that contains all recommended plugins, and Jenkins Docker Plugin. The image was configured so plugins and the WAR content will be part of the image, while $JENKINS_HOME is written on an external volume on the host system:
Build it with:
docker build -t jenkins-with-plugins .
Help
docker run --rm jenkins-with-plugins --help
Networking
If planning to execute Jenkins with a Docker plugin, while the Docker server is installed on a laptop with dynamic DHCP address, it may be necessary to start the Docker server in a non-default networking mode. For context, see 'Docker Hostname or IP address' configuration section of the Docker Plugin.
create a dedicated user-defined bridge network named "jenkins-cloud" and start the Jenkins container so it will connect to that network. This is to take advantage of automatic DNS resolution between containers when Docker Jenkins agents call into the master:
docker network create --driver=bridge jenkins-cloud
Details on how to configure Docker-based agents are found here: Jenkins Server Configuration for Docker Plugin.
Run
The following command line assumes that the image was modified to maintain the plugin and WAR directories in custom locations:
The instance will be available at http://localhost:8080/