My end goal is to have several Python containers running different processes communicate to each other via an ActiveMQ Artemis container. I'm new to all of this, so as a start, I'm just trying to get a proof of concept running.
I followed instructions from this youtube video to build my image of Artemis and everything jives nicely there. I also followed this tutorial to get started sending messages via stomp to Artemis. When I run this script locally (from PyCharm) while my Artemis container is up and running, I can see in the web console that there is a new generated queue from the python script. However, when I containerize the same Python script, I get an error
Could not connect to host localhost, port 61613
Could not connect to host localhost, port 61613
Could not connect to host localhost, port 61613
Traceback (most recent call last):
File "/code/./main.py", line 5, in <module>
import sendAMessage
File "/code/sendAMessage.py", line 30, in <module>
conn.connect('admin', 'admin', wait=True)
File "/usr/local/lib/python3.9/site-packages/stomp/connect.py", line 164, in connect
self.transport.start()
File "/usr/local/lib/python3.9/site-packages/stomp/transport.py", line 109, in start
self.attempt_connection()
File "/usr/local/lib/python3.9/site-packages/stomp/transport.py", line 819, in attempt_connection
raise exception.ConnectFailedException()
I tried setting up a network in docker and putting both containers onto it. I'm running my python container using
docker run --rm --net my-network -p 5000:5000 myimage
I have a feeling I'm incorrectly exposing a port, or something silly like that, but I'm just not quite familiar enough with containers to know where to start looking.
masseyb's answer helped point me the right way.
The way I fixed it was getting the IP address of my ActiveMQ container (docker network inspect) and putting that in the .py script instead of 'localhost'.