O'Reilly logo
live online training icon Live Online training

Docker for JVM projects

End-to-end automation workflows for containerized Java applications with Docker

Benjamin Muschko

Want to use Docker with your Java Virtual Machine (JVM) projects but don’t know where to start? You’ve come to the right place.

Join expert Benjamin Muschko to learn how Docker can help you deliver reliable, containerized software as part of your automation process. You’ll containerize, distribute, and test a Java application with Docker and explore the tooling integration for Docker, including IDEs, build tools, and CI, to make you even more productive. You’ll leave with a firm understanding of the role Docker plays in the development lifecycle and prepared to immediately use Docker in your own JVM projects.

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

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

  • Tooling that helps with managing and abstracting Docker operations for JVM projects
  • How to implement typical developer workflows using Docker

And you’ll be able to:

  • Build images for your JVM applications and distribute them to a Docker registry
  • Write and execute different types of tests that use Docker containers as fixtures
  • Automate the use of Docker from the IDE, the build process, and a CI/CD pipeline

This training course is for you because...

  • You’re a developer of JVM applications who wants to understand how Docker can make your life more productive.
  • You work with Docker on the command line and want to further automate your interaction with Docker.
  • You already use Docker but want to learn about tooling to become more productive.

Prerequisites

  • Experience with Java application development or any other JVM language
  • A working knowledge of Docker—specifically, using the Docker CLI to manage images (pull, push, create) and containers (create, run, stop), Dockerfiles, and Docker Compose
  • A machine (Linux, macOS, or Windows) with the latest Docker Community Edition, JDK 8 or higher, and IntelliJ Community Edition or Ultimate Edition installed
  • A Docker Hub account
  • Pull the Docker image openjdk:jre-alpine with the command docker pull openjdk:jre-alpine
  • Basic familiarity with JUnit 5 (useful but not required)

Recommended preparation:
- Read Docker: Up and Running, second edition if you need a review of Docker (book)

Recommended follow-up:

About your instructor

  • Benjamin Muschko is a software engineer, and a consultant and trainer with over 15 years of experience in the industry. He’s passionate about project automation, testing and Continuous Delivery. Ben is the author of Gradle in Action (Manning). He is a frequent speaker at conferences and is an avid Open Source advocate.

Schedule

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

Introduction (15 minutes)

  • Group discussion: What’s your experience with Docker as a Java developer?
  • Lecture: A brief review of Docker concepts and terminology; typical Docker workflows for JVM developers

Containerization and distribution of JVM projects (65 minutes)

  • Lecture: Writing a Dockerfile for a Java application; building an image for a Java application; running the Java application in a container; pushing an image to a registry; introducing Google Jib for abstracting the workflow
  • Hands-on exercise: Use the Docker CLI to produce an image; run a previously built image in a container; use the Docker CLI to push an image to Docker Hub; use Jib to implement the containerization workflow
  • Q&A

Break (5 minutes)

Resilient, reproducible testing with Docker containers (65 minutes)

  • Lecture: Different types of testing; benefits of using Docker containers for testing; introduction of TestContainers; testing a multicontainer application stack

  • Demonstration: Setting up, configuring, and using TestContainers with JUnit 5

  • Hands-on exercise: Use TestContainers to write a test for a web service; use Docker Compose with TestContainers
  • Q&A

Break (5 minutes)

Integrating Docker with JVM tooling (65 minutes)

  • Lecture: Using Docker from the IDE (IntelliJ and Eclipse); using Docker from the build tool (Maven and Gradle); powering a Jenkins CI/CD pipeline with Docker

  • Hands-on exercise: Run a container from IntelliJ Community Edition; run a container from Maven or Gradle; model Jenkins build pipeline steps that use Docker

Wrap-up and Q&A (20 minutes)