debug spring-boot in docker debug spring-boot in docker docker docker

debug spring-boot in docker


i have to realize that in the dockerFile the Expose command only do the half of work, this mean that only expose the port inside the docker, but not outside, in your example the result will be like this:

enter image description here

Debug works with the JAVA_OPTS and remote debug, the dockerFile looks like this:

FROM frolvlad/alpine-oraclejdk8:slimVOLUME /tmpADD gs-spring-boot-docker-0.1.0.jar app.jarRUN sh -c 'touch /app.jar'ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /app.jar" ]

and executing this command:

docker run -e "JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y" -p 8080:8080 -p 8000:8000 -t springio/gs-spring-boot-docker

As you can see, you should expose the debug port, during the run, in my case(eclipse) 8000

enter image description here

enter image description here


Hi I faced the same problem.

I added the following to the entrypoint in the Dockerfile:

"-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"

Now it looks like this:

FROM java:8VOLUME /tmpADD realName*.jar app.jarEXPOSE 4786RUN sh -c 'touch /app.jar'ENTRYPOINT["java","-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

I did not Exposeport 8000 in the Dockerfile.

Hope this helps.


I think the reason for this might be, your Virtual Box VM configuration does not tunnel the debug port to the host machine.

Check this linkhttps://github.com/boot2docker/boot2docker/blob/master/doc/WORKAROUNDS.md

Basically, in your case, you have to command prompt and run

VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port8000,tcp,,8000,,8000";

Note : Make sure VBoxManage is in your PATH