Connecting to remote activemq instance running on docker container

I have 2 docker containers, one running a spring app (in tomcat) and one running an active mq instance. When I try to connect to it from my spring app, I get the following error. Only activeMQ is running on the one container and the port is properly exposed. I verified the IP address of the docker container (shown below) and that is correct.

I’m not sure what could be causing this error at this point. Any thoughts would be appreciated.

  • How to run services on startup in docker container
  • Getting all open connections within a docker image
  • Error logging in docker running nginx, php-fpm
  • Docker build causes vagrant image to lose connection
  • DEIS no public IP's
  • Docker port binding doesn't seem to work
  • ERROR [activemq.broker.BrokerService] Failed to start Apache ActiveMQ ([mybroker, ID:489af431756c-60313-1409695404227-0:1], java.io.IOException: Transport Connector could not be registered in JMX: Failed to bind to server socket: tcp://172.17.0.2:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600 due to: java.net.BindException: Cannot assign requested address)

  • PHPfpm and Nginx not working in Docker with Supervisord
  • Running Elastic Search with Laradock
  • Files changes not reflected in Docker image after rebuild
  • Why patch linux kernel on Centos for using Docker.io
  • Docker compose not finding my index.js
  • Play change RUNNING_PID file path
  • One Solution collect form web for “Connecting to remote activemq instance running on docker container”

    You configured Spring to start a broker service on 172.17.0.2, which is the IP of the remote machine. Instead, you should configure Spring to connect to an existing broker on that machine. From the ActiveMQ documentation and using the Spring facility JMSTemplate:

    <!-- a pooling based JMS provider -->
    <bean id="jmsFactory"
          class="org.apache.activemq.pool.PooledConnectionFactory"
          destroy-method="stop">
      <property name="connectionFactory">
        <bean class="org.apache.activemq.ActiveMQConnectionFactory">
          <property name="brokerURL">
            <value>tcp://activemq-host.local:61616</value>
          </property>
        </bean>
      </property>
    </bean>
    
    <!-- Spring JMS Template -->
    <bean id="myJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
      <property name="connectionFactory">
        <ref local="jmsFactory"/>
      </property>
    </bean>
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.