Integrating the CloudBees Jenkins Platform with Docker Hub 2.0

DZone 's Guide to

Integrating the CloudBees Jenkins Platform with Docker Hub 2.0

A review of how to integrate Docker Hub with CloudBees' Jenkins Platform, as well as its major use cases.

· DevOps Zone ·
Free Resource

Docker is an incredibly hot topic these days. Its role in Jenkins infrastructures will soon become predominant as companies are discovering how Docker fits within their own environments as well as how to use Docker and Jenkins together most effectively across their software delivery pipelines.

The major use cases for Docker in a Jenkins infrastructure are:

  • Customize the build environment: Different applications often require different build tools, some of these tools require root permissions to be installed on the build servers (x11/xvfb and Firefox for headless tests such as selenium, ImageMagick...). Jenkins admins once solved this problem by increasing the number of flavors of Jenkins slaves, but it was limited by hardware constraints and was not flexible for project teams. The CloudBees Docker Custom Build Environment Plugin and the CloudBees Docker Workflow Plugin offer a new way to solve this challenge with much more flexibility, allowing Jenkins admins to manage only one flavor of Jenkins slaves—Docker enabled slaves—and let the project team customize their build environment to their needs running their jobs in Docker containers.
  • Ship applications as Docker images: More and more applications get shipped as Docker images (instead of war/exe/... files) and the Continuous Integration platform has to build and publish these Docker images.

For these scenarios, the Jenkins infrastructure needs to access to a Docker registry to retrieve/pull the Docker images used on Docker enabled slaves and to store/push the Docker images created by Jenkins builds.

Docker Hub

The Docker Hub is the cloud-based registry service proposed by Docker, Inc that combines the "official" registry of public images on which "every" Docker user relies with a private registry that will allow the user to manage private images.

Integrating a Jenkins infrastructure with Docker Hub requires architecture decisions that are similar to the decisions to integrate a Jenkins infrastructure with online services such as GitHub or BitBucket.

Direct Connectivity From the Jenkins Infrastructure to Docker Hub

The most straightforward solution is to simply open network connectivity (http and https) from the Jenkins slaves to Docker Hub.

Architecture: Jenkins infrastructure and hub.docker.com

Connecting the Jenkins Infrastructure to Docker Hub Through a Proxy

Several organisations will prefer to secure the connectivity of the Jenkins infrastructure to the "outside world" with firewalls and proxies.

To do so, it is necessary to declare the HTTP proxy in the configuration of the Docker daemon on each Jenkins slaves as documented in Docker Documentation - Control and configure Docker with systemd - HTTP Proxy.

Sample /etc/systemd/system/docker.service.d/http-proxy.conf:


Architecture: Jenkins infrastructure and hub.docker.com through an HTTP proxy

Private Docker Registries Behind Firewalls?

This blog post covered how to integrate a Jenkins infrastructure with the Docker Hub public registry service. We will cover in seperate post the integration of a Jenkins infrastructure with a private registry behind the firewalls.

Accessing the Docker Hub Registry in Jenkins Jobs

To see how to access to the Docker Hub registry and to manage your credentials in Jenkins jobs, please read Nicolas de Loof's blog post Docker Hub 2.0 Integration with CloudBees Jenkins Platform and watch the screencast:

continuous delivery, docker, jenkins

Published at DZone with permission of Cyrille Le Clerc , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}