How can i debug the the docker container(storm crawler) which is written in java in vs code?

396 views Asked by At

I am unable to get how can i debug the docker container(which is running storm crawler) in the vs code? I tried looking for https://code.visualstudio.com/docs/containers/debug-common and other https://github.com/DigitalPebble/storm-crawler/wiki/Debug-with-Eclipse. But I did not anything, like how can i configure launch.json file for the same.

Can anyone guide me how can i do this?

2

There are 2 answers

0
Vishal Sinha On BEST ANSWER

This solves problem for me: Writing launch.json file as :

{
    "version": "0.2.0",
    "configurations": [
       {
           "type": "java",
           "name": "Debug (Attach) - Remote",
           "request": "attach",
           "hostName": "localhost",
           "port": 8000,
       }
    ]
}

and connecting it to docker container of storm crawler as:

version: "3"

services:
  storm-jar:
    command: bash -c "storm kill crawler -w 0 ; storm local target/stormcrawler-1.0.jar org.apache.storm.flux.Flux es-crawler.flux --sleep 86400000" 
    environment:
      - STORM_JAR_JVM_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
    ports:
      - 8000:8000

where enviroment to debug storm crawler has been provided on wiki page of github of storm crawler: https://github.com/DigitalPebble/storm-crawler/wiki/Debug-with-Eclipse

0
Frederick Haug On

If you are trying to use the Docker Debugger provided by VSCode, I think you will run into weird issues. The documentation states

The Docker extension currently supports debugging Node.js, Python, and .NET Core applications within Docker containers.

In my experience, editing your Java code and Dockerfile, then rebuilding and rerunning the container helps me make edits and poke around my code for any issues.

Dockerhub may be a good place to search for help too