As I wrote in a previous article, you can run Glassfish in a Docker container.
The purpose of Docker is to package everything into a container so that you can run your application anywhere in a consistent state. To achieve this with a web application and Glassfish, you package the Java virtual machine (JDK 8), Glassfish 4.1 and your web application together.
I created an example of using my base Glassfish image with the Primefaces showcase war file:
FROM koert/glassfish-4.1 MAINTAINER Koert Zeilstra <email@example.com> RUN wget http://repository.primefaces.org/org/primefaces/showcase/5.2/showcase-5.2.war -O /opt/app/deploy/showcase.war
This will download the war file and put it into the /opt/app/deploy directory – the startup script will copy this file into the Glassfish autodeploy directory. When Glassfish starts up, it will automatically deploy the war and you can access the applciation after starting with:
docker run -d -p 8080:8080 koert/glassfish-showcase
On my laptop it starts up in about 12 seconds, you can look at the application in your browser: http://localhost:8080/showcase
Look at my example on Github: https://github.com/koert/docker-glassfish-showcase