Idea logo

The IntelliJ IDEA Blog

The Capable & Ergonomic Java IDE by JetBrains


Debug your Java applications in Docker using IntelliJ IDEA

The Docker integration enables you to build or pull Docker images and run Docker containers directly from IntelliJ IDEA. You can use special run configurations to run your application in a Docker container and see how it will behave in an environment identical to production. But what about debugging? Well, starting from version 2019.1 you can debug Java applications running in Docker containers directly from IntelliJ IDEA.

An application running inside a Docker container is treated as a remote application, so you can attach the debugger to it. IntelliJ IDEA includes a special type of run/debug configuration for remote debugging. You create a remote debug configuration and add a special Before launch task for it: Launch Docker before debug, which defines the Docker configuration that you want to run and attach to.

Remote debug configuration for a Java application running in a Docker container

Now every time you run the remote debug configuration, it will run the container according to the Docker run configuration settings and then attach the debugger to the application in your container. When it hits a breakpoint, the debugger will stop and let you analyze the current state of the application, just like a normal debugging session.

Debug session of a Java application running in Docker

This can be used for any type of Docker run configuration: whether it is based on a built Docker image, a Dockerfile, or a Docker Compose file. For more information about remote debugging in a Docker container and tutorials with examples, see the IntelliJ IDEA documentation.

This improvement enhances the Docker integration for developers who often utilize containers in their workflow. It is available in IntelliJ IDEA Ultimate Edition starting from version 2019.1.

NOTE: Remote debugging in Docker containers is currently implemented for Java 8 and earlier versions. Support for Java 9+ will be added in the nearest future.

Let us know what you think about this feature in the comments below. If you have suggestions for improvement, file a ticket in YouTrack.

Follow us on Twitter: @intellijidea

Comments below can no longer be edited.

4 Responses to Debug your Java applications in Docker using IntelliJ IDEA

  1. Avatar

    Mushon says:

    April 30, 2019


    But I dont see my self use it often. In case i need to debug production env i would stuck to the tradintional way which is to debug a clone of my prod env which is often a stack of container and several VMs.

  2. Avatar

    Mushon says:

    April 30, 2019

    Single app has so many depandencies and if it doesn’t i would keep on debugging my unit test.

    Anyway thanks intellij team are doing such a great product!!

  3. Avatar

    Abtin says:

    May 2, 2019

    Once support for Java 9+ is added, will it be possible to remotely debug applications in which the Java version between the host and container differs?

    For example if developing on a macOS host with Java 8 installed, will it be possible to remotely debug an application in a Docker container using a Java 12 image? What about alternate distributions such as alpine or OpenJ9?

  4. Avatar

    nullsteph says:

    June 17, 2019

    Being able to do this would greatly decrease you dev-setup, and allow us to keep environment changes centralized to the containers and docker-compose scripts. Getting this working would be a big plus.

    Kudos Jetbrain team.

Discover more