Flexibility first - Payara Docker Images Allow a Completely Custom Start-up Configuration

Photo of Ondrej Mihályi by Ondrej Mihályi

We work hard to make Payara Server robust, reliable and innovative so that it's perfect for production deployments. But we never forget about the users and developers. For them, we target flexibility and ease of use in every new feature we add and every tool in the ecosystem we maintain. Our Payara Docker images are an example of it and we're happy for the positive feedback from the user community we're receiving, as well as for the constructive suggestions that help us improve user experience in the future.


  Using Payara Server with Docker -   Guide Download Using Payara Micro with Docker -   Guide Download


We've designed the Payara Docker images so that the image can be used from scratch and also everything can be easily configured without building a custom Docker image:

  • when the Docker container is started, Payara Server is started automatically
  • one or more applications can be dropped into a local directory mounted as a Docker volume and they will be deployed upon start-up
  • it's possible to choose between 2 different domain configurations just using the PAYARA_DOMAIN environment variable
  • it's possible to modify the Docker ENTRYPOINT to completely customize how Payara Server is started

While most of the above aims at ease of use, the last point is especially important to give users flexibility. The core parts of the ENTRYPOINT are extracted into separate scripts, which you may reuse to create a custom ENTRYPOINT:

  • 0 - a script that starts Payara Server in foreground with optimization of memory usage. It does the same thing as but it only keeps one JVM process running instead of two
  • - script that generates a command file to deploy all applications found in a deployment directory. This command file is used as a post-boot command file to deploy the applications at server's start-up

In the end, the default entry point does the following:

  1. runs to generate the command file to deploy detected applications at start-up
  2. starts Payara Server in the foreground with the 0 script and passes the generated command file to it

If you need to modify the command file script, e.g. to add a datasource during server start-up, you can create a custom command file and append the generated command file to it. This is exactly what one of our fellow community members with the handle ofspain did and shared with us on github:

You guys are the bomb!!!!...
Just copy and pasted this into my dockerfile while replacing necessary parameter e.g hostname database name etc


ENTRYPOINT ${PAYARA_PATH}/generate_deploy_commands.sh &&
echo 'create-jdbc-connection-pool --datasourceclassname org.postgresql.ds.PGConnectionPoolDataSource
--restype javax.sql.ConnectionPoolDataSource --property user=postgres:password=:DatabaseName=fin_dev:ServerName=$HOST_IP:port=5432 fing-pool' > mycommands.asadmin &&
cat ${DEPLOY_COMMANDS} >> mycommands.asadmin &&
${PAYARA_PATH}/bin/asadmin start-domain -v --postbootcommandfile mycommands.asadmin ${PAYARA_DOMAIN}'


I have been battling for days before coming across this article.....Thanks a million times buddies

In the near future, we plan to simplify this even further by moving a part of the ENTRYPOINT into the CMD section in the Dockerfile so that it's possible to do the same thing just by writing the asadmin commands into a file and executing the following (production is the name of the domain, which always has to come last):

docker run -p 8080:8080 payara/server-full --postbootcommandfile mycommands.asadmin production

The issue is already raised here, stay tuned...