O'Reilly logo
live online training icon Live Online training

Continuous delivery with Jenkins and Docker

Leverage Jenkins 2 and Docker to simplify and standardize your pipeline

Brent Laster

Jenkins's updated support for pipelines makes it easy to create and use Docker containers to streamline and standardize the pipeline stages, enabling a new approach to continuous delivery (CD). But there are a myriad of ways to use Docker: as a Docker cloud node, as an agent running Docker, as a built-in environment, and as a tool that can be invoked separately. Additionally, there are new built-in methods for creating containers, building images, and automatically starting and stopping Docker instances. Using a combination of these approaches provides flexibility and simplicity in building up a CD pipeline, but to get the most benefit (and not be overwhelmed), you have to understand all available options and approaches.

Join expert Brent Laster to learn how to create both simple and complex Docker images on the fly and run them as containers that are automatically started, stopped, and monitored. Over three hours, you’ll gain a deep understanding of and hands-on experience using methods for simplifying and managing Docker containers through Jenkins.

What you'll learn-and how you can apply it

By the end of this live, online course, you’ll understand:

  • How Jenkins and Docker can work together
  • The best approaches for using Docker as a Jenkins agent
  • How to integrate Docker into pipelines and processes

And you’ll be able to:

  • Set up and define standalone Docker agents for Jenkins
  • Configure a Docker cloud for use by Jenkins
  • Define default Docker registries, nodes, and installations for use in pipelines
  • Use Jenkins’s DSL to automatically create new images and launch containers

This training course is for you because...

  • You're a software professional with Jenkins experience who wants to leverage containers in your continuous delivery processes.
  • You're a software professional with Docker experience who wants adapt Jenkins into your software development pipeline.

Prerequisites

  • A basic understanding of Jenkins and Docker

Required materials and setup:

Recommended preparation:

About your instructor

  • Brent Laster is a global trainer, author, and speaker on open source technologies as well as a senior R&D manager at a top technology company. He has been involved in the software industry for more than 25 years, holding various technical and management positions.

    Brent has always tried to make time to learn and develop both technical and leadership skills and share them with others. He believes that regardless of the topic or technology, there’s no substitute for the excitement and sense of potential that come from providing others with the knowledge they need to accomplish their goals.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Introduction to Jenkins 2, Docker, and configuring a container as a standalone Jenkins agent (30 minutes)

  • Lecture: The most important features of Jenkins 2; how Docker differs from a VM; methods for incorporating Docker into your pipeline—Docker image manually managed as a separate agent, configured as a “cloud” as a standalone Jenkins agent, invoked via the special DSL docker global variable and its associated methods, and directly in the script via the DSL shell call (sh); configuring a Docker image to be manually managed as a separate agent in Jenkins 2
  • Hands-on exercise: Create a standalone agent from a Docker image

Docker containers as cloud agents (20 minutes)

  • Lecture: Cloud agents; configuring Docker images to function as cloud agents; the differences between creating agents in the Jenkins 2 scripted format and the declarative format
  • Hands-on exercise: Configure the Docker plugin to use as a cloud

Break (10 minutes)

Using Docker agents in stages of the pipeline (25 minutes)

  • Lecture: How Docker agents can be used to run applications within individual stages of a Jenkins 2 CI/CD pipeline; key functions that can be used in Jenkins 2 to help simplify the processes of defining the agents and using them across multiple nodes, including the Pipeline Model Definition plugin for defining a default template for Docker containers
  • Hands-on exercise: Use a Docker agent in a pipeline stage

Segment 4: Working with the Docker global variable—Part 1 (25 minutes)

  • Lecture: Global variables in Jenkins 2; how the Docker global variable can be used for working with the Docker application itself, Docker images, and Docker containers
  • Hands-on exercise: Use the Docker global variable to create an image and put it into your local repository

Break (10 minutes)

Working with the Docker global variable—Part 2 (20 minutes)

  • Lecture: Using the Docker global variable to easily and powerfully execute commands in pipelines that run within the container
  • Hands-on exercise: Use the Docker “inside” method to start up a container, map volumes, and execute commands easily within it

Using the DSL shell steps to invoke Docker; leveraging multiple containers working together (30 minutes)

  • Lecture: How Docker can be invoked from a pipeline script via calls to the OS shell; the advantages and disadvantages of this approach; the “sidecar” pattern for linking containers in pipelines
  • Hands-on exercise: Link a database image and a frontend image to form the application; have the script print out a link where you can access the running application

Wrap-up and Q&A (10 minutes)