How to debug a Glassfish application running with Docker Compose

Mangu :

I have a Java EE app running on Glassfish, and I have Glassfish running in a container, using Docker and Docker Compose.

I want to know if it's possible to debug this app running on the Glassfish container, as you would debug a regular Java app, from Intellij IDEA.

I've tried something like this but it hasn't worked for me.

My docker-compose.yml includes (removing other private info):

services:
  glassfish:
    tty: true
    build: glassfish
    ports:
    - "8080:8080"
    - "4848:4848"
    - "80:80"
    - "9009:9009"

Dockerfile includes (removing other non related info):

EXPOSE 8080 4848 80 9009

COPY 010_entrypoint.sh /docker-entrypoint.d/

ENTRYPOINT /docker-entrypoint.d/010_entrypoint.sh

And in 010_entrypoint.sh file (removing other non related info):

/opt/glassfish4/glassfish/bin/asadmin start-domain --debug
Marco :

Running glassfish server on a docker is like running it on a remote server so you have to setup remote debugging.

You have t make sure:

a) Your Glassfish server is running in debug mode b) You have configured port 9009 on your docker so the debugger can connect to it (you need to have a line like this in your docker-compose.yml: - 9009:9009)

Then you have to configure your debugger to connect to localhost:9009

Finally if you share your Dockerfile an docker-compose.yml it will be easier to understand what is going wrong.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=105783&siteId=1