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.

  • creating a docker image with nginx compile options for Optional HTTP modules
  • Is there a way to use a remote API as an endpoint in a docker compose file?
  • Couchbase XDCR in a Docker container
  • Docker-compose fails with error “No command specified”
  • Passing parameter in docker build command with fish
  • Adding bind-mounts to the containers for running a task in concourse
  • 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)

  • Logging to stdout in supervisord with docker
  • How to set HOST_GID for Docker
  • How to import SHP file into docker PostgreSQL container?
  • Docker: reload a nodejs app with nodemon
  • Using Redis and mysql with docker container
  • I can't see inside the container with a vnc
  • 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.