Remote debugging for containerized application using IntelliJ

Annapurna Pingale
3 min readJan 3, 2021

In the era of containerization, debugging becomes hard and important at the same time. I’ve been facing issues for the same reason. Then came across, the remote debugging option by IntelliJ. The debugger is a powerful tool, which lets you find bugs a lot faster by providing an insight into the internal operations of a program.

This article will help you in setting up the remote debugging environment.

Prerequisites :

  1. Docker
  2. IntelliJ
  3. Gradle

STEPS :

  1. Clone the git repository :
git clone https://github.com/cognitiveskull/remote-debugging-app.git

2. Go inside the repository and build the jar

cd remote-debugging-app && gradle build

3. Build the docker image

docker build -t remote-debug:latest .

4. Start the Containerized application

docker run -p 8080:8080 -p 9000:9000 remote-debug:latest

5. Verify the application is running using health endpoint

GET : http://localhost:8080/actuator/health

6. Now lets setup IntelliJ debug configuration

  • Open the project in the IntelliJ
  • Click Run -> Edit Configuration
  • Click on Add new configuration
  • Select remote. (In latest versions of IntelliJ it changed to remote JVM debug)
  • Add name to the configuration and Modify port (as of now 9000) then click on ok.
  • Click on the debug icon and you’ll be able to see debugger getting attached to the docker process on port 9000.
  • Set the debug point wherever necessary.
  • Hit the endpoint from the postman
  • You’ll get redirected to the IntelliJ in debug mode and now you can start debugging your code.

References :

Thanks for reading…..!!

--

--