5 Replies Latest reply on Aug 23, 2018 7:18 AM by pejonsson

    Docker variables in JBoss


      Hi All


      I am currently working on containerising our JBoss application. I have managed to successfully create a working JBoss Application container,however I have hard coded many of configs like Datasource ip/user/password as well as system properties.


      My Dockerfile has basically the following steps:

      1. From Centos
      2. Download and extract EAP and JAVA
      3. Copy a configuration.sh script and execute it
        1. This script starts jboss, runs a few cli to configure Datasources etc and stops JBoss
      4. Lastly Start JBoss


      If I want to move my code to another environment DEV -> UAT as an example. I would need to change or create a new configuration script that has the new Datasource URL/User/Password etc. This would mean I would have a different container for each environment.


      My question is:


      Is it possible to use some sort of variable for config within standalone.xml

        • 1. Re: Docker variables in JBoss

          Is it possible to use some sort of variable for config within standalone.xml.


          Yes.it is allow us to use the environment variable in wildfky as following  ${env.DB_CONNECTION_URL} :


          1. <subsystemxmlns="urn:jboss:domain:datasources:4.0">
          2. <datasources>
          3. <datasourcejndi-name="java:jboss/datasources/ExampleDS"pool-name="ExampleDS"enabled="true"use-java-context="true">
          4. <connection-url>${env.DB_CONNECTION_URL}</connection-url>
          5. <driver>mysql</driver>
          6. <security>
          7. <user-name>${env.DB_USERNAME}</user-name>
          8. <password>${env.DB_PASSWORD}</password>
          9. </security>


          You can see the following link which explains how we can use it in OpenShift :  JBoss EAP Environment Variables | OpenShift Developers      You can do it on your local system as well.

          • 2. Re: Docker variables in JBoss

            Hi Amit Nijhawan


            I have come across this option and have tried it. However what I did not like about this option was the standalone.xml has the ${env.DB_CONN} and I hoped it actually replaced the variable with the value on startup.

            • 3. Re: Docker variables in JBoss

              Do you want to pass through environment variables to the container? Is it your requirement?

              • 4. Re: Docker variables in JBoss

                When I start the container I do not want to see variables in the standalone.xml , I want the values.


                What's the best practice when it comes to JBoss Docker images in different environments, Dev/QA/PROD?

                • 5. Re: Docker variables in JBoss

                  I disagree with your request of "seeing the value" instead of the variable?

                  How can you then know if there is a hardcoding in that specific image of the datasource setting or if it is based on variables?


                  Can you run the ENV command inside the running container and see your variables maybe?