使用Docker-Compose时,使用JPDA进行远程调试不会通过eclipse连接到Tomcat [英] Remote Debugging with JPDA won't connect to Tomcat through eclipse when using Docker-Compose

查看:256
本文介绍了使用Docker-Compose时,使用JPDA进行远程调试不会通过eclipse连接到Tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Docker的新手,所以这很简单,我做错了。
有了所有解决方案之后,当使用 Docker run启动Tomcat容器时,我已经能够使用eclipse进行远程调试。

I'm very new to Docker so this could be something simple I'm doing wrong. With all the solutions out there I've been able to get remote debugging working with eclipse when using 'Docker run' to launch the Tomcat container.

docker run -it --rm -e JPDA_ADDRESS = 8000 -e JPDA_TRANSPORT = dt_socket -p 8888:8080 -p 8000:8000 tomcat:8.0-jre8 /usr/local/tomcat/bin/catalina.sh jpda运行

但是,当使用docker-compose时,出现无法连接到远程VM。连接被拒绝对话框。

However when using docker-compose, I get a "Failed to connect to remote VM. Connection refused" dialog.

docker-compose up

docker-compose.yml设置:

docker-compose.yml settings:

tomcat:
图片:tomcat:8.0-jre8
#开始-远程调试设置
#Didn无论是否使用此network_mode设置,都无法使用。但是,通过 docker container inspect * CID *看到的桥接设置看起来与工作解决方案
network_mode几乎相同:bridge
环境:
-JPDA_ADDRESS:8000
-JPDA_TRANSPORT: dt_socket
入口点:/usr/local/tomcat/bin/catalina.sh jpda run
#结束-远程调试设置
部署:
restart_policy:
条件:开启-failure
放置:
约束:[node.role == manager]
端口:
-8888:8080
#远程调试设置jpda端口
-8000:8000

我与 docker run一起使用的日食设置为:

My eclipse settings that work with 'docker run' are:

远程Java应用程序:
主机:localhost
端口:8000

注意:使用docker-compose设置,我还会在启动输出中看到预期的打印结果:

Note: With the docker-compose settings I also see the expected print in the startup output:

在地址8000侦听传输dt_socket

和als o对于这两种部署,我都可以通过公开的端口8888访问Web服务的功能。这个简单的链接返回 Hello。

and also with both deployments I can access the web service's functionality through the exposed port 8888. ie. This simple link returns 'Hello'.

http:// localhost:8888 / MyEmulatorService / rest / MES /

任何关于为什么我无法以这种方式启动时进行远程调试的想法?我怀疑网络配置的设置方式之间存在细微的差别。

Any thoughts on why I can't remote debug when launching this way? I suspect there's a subtle difference in the way the network configuration is setup.

推荐答案

我的一个伙伴发现了这一点。即使启动输出显示一切正常,并且catalina.sh使用的默认端口和传输为8000,dt_socket。

A buddy of mine figured this out. Even though the startup output makes it appear as everything is working and the default port and transport used by catalina.sh is 8000, dt_socket.

未传递环境变量进入容器,这会导致破损。也许其他人可以解释这对.sh脚本有何影响?

The environment variables were not being passed into the container and this was causing the breakage. Maybe someone else can explain how that impacts the .sh script?

通过隧道进入容器并列出环境变量可以检测到此问题。

This problem was detected by tunneling into the container and listing the environment variables.

docker exec -it *CID* bash
env

对我的更改docker-compose.yml文件现在看起来像:

The change to my docker-compose.yml file now looks like:

   environment:
     JPDA_ADDRESS: 8000
     JPDA_TRANSPORT: dt_socket

这篇关于使用Docker-Compose时,使用JPDA进行远程调试不会通过eclipse连接到Tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆