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.
This article is outdated. Download the latest version of IntelliJ IDEA and follow the steps listed in our Run and debug a Spring Boot application using Docker Compose tutorial.
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.
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.
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
Subscribe to Blog updates
Build a Spring Boot App with AI Assistant
In this article, we’ll be building a small Java Spring Boot web application in IntelliJ IDEA with the help of JetBrains AI Assistant. If you’d like to follow along with this tutorial, you’ll need IntelliJ IDEA Ultimate, as well as an active subscription to AI Assistant or the free seven-day trial…
Top 10 UI Updates in IntelliJ IDEA for 2023
Hey there, fellow developers! Today, we want to share the most significant UI updates from 2023 that have transformed how IntelliJ IDEA looks and functions. New UI Of course, the highlight of our recent updates was the launch of our new, clean, and modern UI. This was first announced at the en…
The What, Why, and How of JPA Buddy in IntelliJ IDEA
Master JPA entity management with JPA Buddy in IntelliJ IDEA! Our latest article shows you how to simplify your workflow and reduce boilerplate code.
The Best of IntelliJ IDEA’s HTTP Client
In today's fast-paced tech world, easy and efficient management of web services and APIs is crucial. That's where IntelliJ IDEA's HTTP Client steps in, turning complex HTTP requests into a walk in the park. The HTTP Client is a feature-rich, text-based tool in IntelliJ IDEA Ultimate. It seamlessl…