OS: Ubuntu 18 / Windows 10
Java: OpenJdk 12
Docker Container: Sprint boot application
To connect Remote Debug in Eclipse you can follow these steps:
- Put these lines in your application Dockerfile
# For Windows Machine comment EXPOSE 7074 and add it to docker-compose.yml
EXPOSE 7074
ENV DEBUG_INFO="-Xdebug -Xrunjdwp:transport=dt_socket,address=0.0.0.0:7074,server=y,suspend=n"
ENTRYPOINT [ "sh", "-c", "java ${DEBUG_INFO} -Dspring.profiles.active=docker -jar /pharmacy-service.jar" ]
For Windows, add ports in docker-compose.yml
bank-service:
image: ....
environment:
...
ports:
- 9097:9097
- 7074:7074
- For Linux only, bring your docker application up and search for network, in my case ecs-core_default
$ docker network ls
NETWORK ID NAME DRIVER SCOPE
e63bb0decc92 bridge bridge local
94aefcdbb5f3 ecs-core_default bridge local
- For Linux only, now check IP for your application using,
$ docker network inspect ecs-core_default
[
{
"Name": "ecs-core_default",
.....
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
.....
"Containers": {
"29bebdc31d6bf2057ed31074407c780cc718396ca49f58e766e098fceaa41a41": {
"Name": "ecs-core_pharmacy-service_1",
"EndpointID": "fadc9b40bfed1d4b2104b96fb6930bda47928256092c268aa4cb67407c2c1661",
"MacAddress": "02:42:ac:12:00:06",
"IPv4Address": "172.18.0.6/16",
"IPv6Address": ""
}
}
.....
}
]
For Linux only, copy IP address from Containers "IPv4Address": "172.18.0.6/16" i.e. 172.18.0.6
For Windows 10 only, to find IP goto Control Panel -> Network and Internet -> View Network Status and task -> Change adapter settings -> Look for vEthernet. Open Properties goto Networking tab, select TCP/IPv4 and then click Properties button and copy IP.

In Eclipse, Run -> Debug Configuration, use IP (screenshot shows IPv4 for Linux, for Windows it will be 172.26.48.1) and exposed port (i.e 7074).

Enjoy!!