Live Debugging Java in Docker – Just in time for JavaOne!

Sep 20 2016

Developing Java web applications often requires that they can be deployed on multiple technology stacks. These typically include an application server and a database, but these components can vary from deployment to deployment. Building and managing multiple development stacks in a development environment can be a time consuming task often requiring unique configurations for each stack.

Docker can simplify the process of building and maintaining develop environments for Java web applications by building custom images that application developers can create on demand and use for development, testing and debugging applications. We have recently published a tutorial for building a Java web application using containers and three popular Java IDEs.  Docker enables developers to debug their code as it runs in containers. The tutorial covers setting up a debug session with an application server in Docker using IDEs that developers typically use such as Eclipse, IntelliJ IDEA and Netbeans. Developers can build the application, change code, and set breakpoints while the application is running in the container. The tutorials use a simple Spring MVC application to illustrate how use containers when developing Java applications

The tutorial is available on GitHub in our Docker Labs repository. These tutorials show you how to:

  • Configure Eclipse, IntelliJ, and Netbeans
  • Set-up the project
  • Debug your application live in the container

You can go to the tutorials, or follow along in these videos:

The tutorial uses common stack components, but the Docker enables you to build development environments using components from different technology stacks. For most use cases, Docker provides a way to quickly create and deploy a consistent development environment in Java.

Have any more tips or examples using Docker for with Java? Or other languages? Share them with the community by contributing to the Docker Labs repository.

Based in San Francisco? Join us this Wed Sept 21st at Docker HQ for a Docker for Java Developers meetup with Docker Captain Arun Gupta and Patrick Chanezon.


3 thoughts on “Live Debugging Java in Docker – Just in time for JavaOne!

  1. Nice article. Thanks a lot. Would you please also shed some light on debugging native Java application (java -jar App.jar) which runs inside docker container. I have tried many options setting different variants of setting JAVA_OPTS like this
    ENV JAVA_OPTS=" \ \ \ \ \ \
    but non of them worked.

    • Avatar for Sophia Parafina

      Orlando Geronimo

      When you `docker run` your container, use `-p 8000:8000` and start it with `/bin/bash` instead of running tomcat right away

      – Once inside the container, edit conf/server.xml and change `<listener … bind=` to your machine's ip address

      – Edit bin/ and add `-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n` to the end of the `JVM_OPTS` variable

      – If you're using Eclipse, go to debug configurations and choose debug as remote java application — name the configuration and attach at localhost:8000

      Hope this helps.

  2. Avatar for Sophia Parafina

    Arnost Pacicka


    I looked at the Netbeans video, but the interaction with Netbeans starts with "open Netbeans, download the project, open the project" while the reason the search engine landed me here was the "configure" part, which I am dealing with right now. Just to let you know that it is a bit disappointing.

Leave a Reply