I developed a java program which is supposed to run in docker. However, I encountered a lot of pains when debugging my java program running in docker.
I searched on Internet, some tutorials proposed tools like spring-dev-tools (as my java program is a spring-boot-based program).
https://www.youtube.com/watch?v=sz5Zv5QQ5ek
Based on thoses tutorials, debugging is ok, such as setting breakpoint and variable watching, however, when I update my code (for instance, some classes), thoses changes cannot be reflected immediately in the program running in docker, the programm behaves as old code.
Can anybody give some hints ?
I have managed to make this work by doing the following:
Here is my dockerfile:
FROM gradle:5.4-jdk12
WORKDIR /app
EXPOSE 8080 5005
and here is my docker-compose.yml:
version: '3'
services:
app:
build:
context: .
ports:
- 5005:5005
- 8080:8080
volumes:
- .:/app
command: ["gradle", "bootRun"]
when I run this using docker-compose up
and then connect a remote debugger, the hot reloading works.
I am connecting from Intellij so I have to rebuild the project for the hot reloading to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With