ActiveMQ within Wildfly on a Docker container gives: Invalid "host" value "0.0.0.0" detected ActiveMQ within Wildfly on a Docker container gives: Invalid "host" value "0.0.0.0" detected docker docker

ActiveMQ within Wildfly on a Docker container gives: Invalid "host" value "0.0.0.0" detected


Here are a few options. Option 1 & 2 may be what you asked for, but in the end didn't work for me. Option 3 however, I think will better address your intent.

 
 
Option 1) You can do this by adding some scripting to your docker image ( and not touching your standalone-full.xml. The basic idea ( credit goes to git-hub user kwart ) is to make a docker entry point that can determine the IPv4 address of the docker container before calling standalone.sh.

see : https://github.com/kwart/dockerfiles/tree/master/wildfly-ext and check out the usage of WILDFLY_BIND_ADDR. I forked it.

Notes:

  • GetIp.java will print out the IPv4 address ( and is copied into the container )
  • dockerentry-point.sh calls GetIp.java as needed
    WILDFLY_BIND_ADDR=${WILDFLY_BIND_ADDR:-0.0.0.0}    if [ "${WILDFLY_BIND_ADDR}" = "auto" ]; then         WILDFLY_BIND_ADDR=`java -cp /opt/jboss GetIp`    fi

 
 
Option 2) Alternatively, using some script-fu, you may be able to do everything you need in a Dockerfile:

#CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-c", "standalone-full.xml", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]CMD ["sh", "-c", "DOCKER_IPADDR=$(hostname --ip-address) && echo IP Address was $DOCKER_IPADDR && /opt/jboss/wildfly/bin/standalone.sh -c standalone-full.xml -b=$DOCKER_IPADDR -bmanagement=$DOCKER_IPADDR"]

Your mileage may very.

I was working with the helloworld-jms quickstart from the WildFly docs, and had to jump through some extra hoops to get the JMS queue created. Even at that point, the sample java code wasn't able to connect with either option 1 or option 2.

 
 
 
Option 3) ( This worked for me btw ) Start your container with binding to 0.0.0.0, expose your 8080 port for your JMS client running on the host, and add an entry in your hosts' /etc/hosts file:

Dockerfile:

FROM jboss/wildfly# CP foo.war /opt/jboss/wildfly/standalone/deployments/RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silentRUN /opt/jboss/wildfly/bin/add-user.sh -a quickstartUser quickstartPwd1! --silentRUN echo "quickstartUser=guest" >> /opt/jboss/wildfly/standalone/configuration/application-roles.properties# use standalone-full.xml to enable the JMS featureCMD ["/opt/jboss/wildfly/bin/standalone.sh", "-c", "standalone-full.xml", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]

Build & run ( expose 8080 if your client is on your host machine )

docker build -t mywildfly .docker run -it --rm --name jboss -p127.0.0.1:8080:8080 -p127.0.0.1:9990:9990 my_wildfly

Then on the host machine ( I'm running OSX; my jboss container's id was 46d04508b92b ) add an entry in your /etc/hosts for the docker-host-name that points to 127.0.0.1:

127.0.0.1 46d04508b92b  # <-- replace with your container's id

Once the wildfly container is running, you create/configure the testQueue via scripts or in the management console. My config came from https://github.com/wildfly/quickstart.git under the helloworld-jms folder:

docker cp configure-jms.cli jboss:/tmp/docker exec jboss /opt/jboss/wildfly/bin/jboss-cli.sh --connect --file=/tmp/configure-jms.cli 

and SUCCESS from mvn clean compile exec:java the host machine (from w/in the helloworld-jms folder):

Mar 28, 2018 9:03:15 PM org.jboss.as.quickstarts.jms.HelloWorldJMSClient mainINFO: Found destination "jms/queue/test" in JNDIMar 28, 2018 9:03:16 PM org.jboss.as.quickstarts.jms.HelloWorldJMSClient mainINFO: Sending 1 messages with content: Hello, World!Mar 28, 2018 9:03:16 PM org.jboss.as.quickstarts.jms.HelloWorldJMSClient mainINFO: Received message with content Hello, World!


You need to edit the standalone-full.xml to cope with jms behind NAT and when you run the docker container pass though the ip and port that your jms client can use to connect, which is the ip of the machine running docker in Dockers' default config