Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

931
Views
How run jboss-cli on start docker container with Dockerfile

I am trying create image docker container with Dockerfile. I need execute some commands with jboss-cli when docker container starts. To execute jboss-cli it is necessary that the wildfly service is running.

My Dockerfile:

FROM jboss/wildfly:latest

USER jboss

RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent

CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

And i tried add a jboss-cli command in my Dockerfile

FROM jboss/wildfly:latest

USER jboss

COPY mysql-connector-java-5.1.44.jar /opt/jboss/

RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent

USER root
#in this line is needed to change owner file to jboss user use this file
RUN chown jboss.root /opt/jboss/mysql-connector-java-5.1.44.jar
USER jboss

CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]
CMD ["/opt/jboss/wildfly/bin/jboss-cli.sh", "-c", "controller=localhost:9990", "--user=admin", "--password=admin", "--command=\"module add --name=com.mysql --resources=/opt/jboss/mysql-connector-java-5.1.44.jar --dependencies=javax.api,javax.transaction.api\""]

when i run the docker run command:

docker run --name=wildfly-ci -p 8080:8080 -p 9990:9990 wildfly-ci

i receive this message error from jboss-cli when run docker command

Failed to connect to the controller: The controller is not available at localhost:9990: java.net.ConnectException: WFLYPRT0053: Could not connect to remote+http://localhost:9990. The connection failed: WFLYPRT0053: Could not connect to remote+http://localhost:9990. The connection failed: XNIO000812: Connection closed unexpectedly

I don't know if is because the wildfly's service is not running yet in this moment or because is a some behavior with Docker Container.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

This works for me:

   RUN /bin/sh -c '$JBOSS_HOME/bin/standalone.sh -c=standalone-full.xml &' && \
      sleep 10 && \
      cd /tmp && \
      $JBOSS_HOME/bin/jboss-cli.sh --connect --command="module add --name=org.postgresql --resources=$JBOSS_HOME/standalone/configuration/postgresql-42.2.5.jar --dependencies=javax.api,javax.transaction.api,javax.servlet.api" && \
      $JBOSS_HOME/bin/jboss-cli.sh --connect --command=:shutdown 


    # User root to modify war owners
    USER root

    CMD ["/opt/eap/bin/standalone.sh", "-c", "standalone-full.xml", "-b", "0.0.0.0","-bmanagement","0.0.0.0"] 
over 4 years ago · Santiago Trujillo Report

0

Try this Dockerfile with single CMD,

Dockerfile

FROM jboss/wildfly:latest

USER jboss

COPY mysql-connector-java-5.1.44.jar /opt/jboss/

RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent

USER root RUN chown jboss.root /opt/jboss/mysql-connector-java-5.1.44.jar USER jboss

CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0",";","/opt/jboss/wildfly/bin/jboss-cli.sh", "-c", "controller=localhost:9990", "--user=admin", "--password=admin", "--command=\"module add --name=com.mysql --resources=/opt/jboss/mysql-connector-java-5.1.44.jar --dependencies=javax.api,javax.transaction.api\""]

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!