You can also start it by the method introduced in "Run Payara with Docker", but I also want to put the app in the Docker image! I want to be able to start it as much as possible with the same feeling as GlassFish! In that case.
reference: ADAM BIEN'S WEBLOG - PAYARA MICRO AND DOCKER http://www.adam-bien.com/roller/abien/entry/payara_micro_and_docker
The linked video explains how to create it without using the official Payara image. The official image of Payara implements about half of what is explained in the video.
The following is an example of deploying WAR_TO_DEPLOY.war
in/ path / to / war /
on the local host (boot2docker or DockerMachine) and starting payara.
Dockerfile
FROM payara/micro
ADD "/path/to/war/WAR_TO_DEPLOY.war" "/tmp/"
ENTRYPOINT java -jar ${PKG_FILE_NAME} --deploy "/tmp/WAR_TO_DEPLOY.war"
I store the war file in / tmp
of the Docker container, and deploy and execute it from there. It does not have to be / tmp
. Variables etc. can be described as written here.
$ docker build -t image name.
$ docker run --name container name-p 8080:8080 -p 4848:4848 -p 8009:8009 -p 8181:8181 -d Image name
It is a description when forwarding all ports EXPOSE with
payara / micro
. In practice, it is enough to specify only the ports you plan to use.
Go to http: // localhost: 8080 / WAR_TO_DEPLOY
.
(Replace the localhost
part with the boot2docker or DockerMachine address as appropriate)
If you need to add settings to your domain, such as when you want to create a connection pool, you also need to do the following:
reference: How do I add JDBC drivers and configure JDBC Resources in Payara Micro? http://stackoverflow.com/questions/32899120/how-do-i-add-jdbc-drivers-and-configure-jdbc-resources-in-payara-micro
Microdomain.xml in Payara repository Will be downloaded. It's like domain.xml for Payara Micro. Edit microdomain.xml and save it as if you were editing domain.xml.
You can easily see what to add and where to add it by creating a set of settings in the Payara or GlassFish admin console, then opening domain.xml to see the diffs.
Make microdomain.xml referenced with the --domainConfig
option when payara starts.
Dockerfile
FROM payara/micro
ADD "/path/to/war/WAR_TO_DEPLOY.war" "/tmp/"
ADD "/path/to/resource/microdomain.xml" "/etc/opt/"
ENTRYPOINT java -jar ${PKG_FILE_NAME} --deploy "/tmp/WAR_TO_DEPLOY.war" --domainConfig "/etc/opt/microdomain.xml"
While running, you may see the message ʻException while persisting domain.xml, changes will not be available on server restart.`, but don't worry. There should be almost no situation where Payara "Micro" is restarted ...
Recommended Posts