• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Docker ApacheMQ connection from outside a container

 
Ranch Hand
Posts: 666
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a springboot consumer using ApacheMQ and loade into into a docker container
One way to connect the container to ApacheMQ  is to create a network on docker

Then load a ApacheMQ container/image onto that locker as part of the network.

docker run -d --name activemqcontainer -p 8161:8161 --network=network rmohr/activemq

This runs ApacheMQ  from the container, To connect to it from the consumer I have in my application.properties

activemq.broker.url=tcp://activemqcontainer:61616

This means that my consumer inside my container can connect to  ApacheMQ running in another container.


My question is can I take the ActiveMQ out of the container and still connnect to it.

So I could have the following Tomcat/Producer ->ActiveMQ -> Docker/container/producer

Thanks for any help
 
Saloon Keeper
Posts: 23689
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't quite get what the "before" and "after" setups are supposed to be, but here's the deal.

Docker can connect to private networks defined to Docker and/or it can connect to the Docker host's network. You can define this when you define NICs to the containers.

Originally, Docker allowed you to link containers so that you didn't need to explicitly give port definitions for linked ports. You only need explicit port IDs for traffic coming in from the host or points beyond. The host may have firewall considerations as well.

The concept of linked containers is deprecated now and it's preferable to use Docker named private networks instead. The old Unix network commands such as "ifconfig" aren't much use here, so the "ip" command can be more helpful. And within Docker, of course, there are Docker-specific inspection commands just to make sure you know where everything is.

So in short, yes, external clients can talk to Docker containers via standard networking and Docker explicit port definitions. Docker containers can network to one another in 2 different (old-and-new) ways. And Docker containers can talk out onto the host's network. So basically anyone can talk to anyone, if you've got everyone agreeing on how.
 
Tony Evans
Ranch Hand
Posts: 666
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, just to make sure I understand what you mean, when you say private networks to link containers. You mean

docker network create network

 
Tim Holloway
Saloon Keeper
Posts: 23689
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep.

There are other types of private networks possible (such as inter-VM networks), and Docker should be able to hook into them as well, but I was specifically thinking of Docker networks.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic