Sep 19, 2018

How to use docker to run GlassFish Java EE application

Use the docker file:
FROM glassfish:latest
MAINTAINER i88.ca"

COPY your.ear /
COPY run.sh /

EXPOSE 8080

ENTRYPOINT ["/run.sh"]

Run GlassFish and Deploy your app (content of run.sh)
#!/bin/sh

/opt/glassfish4/bin/asadmin start-domain
/opt/glassfish4/bin/asadmin -u admin deploy /your.ear
/opt/glassfish4/bin/asadmin stop-domain
/opt/glassfish4/bin/asadmin start-domain --verbose
# or to avoid restart GlassFish
#tail -F /path/to/your/domain/logs/server.log

See also

How to use docker to run Tomcat Java Web application