I am trying to use rabbitmq inside my container. I installed the required libraries and then tried to create a BlockingConnection, but it fails. The same thing works when I try it on any VM or physical host. It fails with containers only. Here are the steps:-
Installing required packages:-
$ docker run -it ubuntu:15.10 /bin/bash
root@d3d44e2656a9#
root@d3d44e2656a9# sudo apt-get -y install python-pip rabbitmq-server wget \
&& pip install pika
Next, I tried to create a BlockingConnection, but it fails. The same thing worked on a VM though.
root@d3d44e2656a9# python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pika
>>> pika.BlockingConnection(pika.ConnectionParameters('127.0.0.1'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 339, in __init__
self._process_io_for_connection_setup()
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 374, in _process_io_for_connection_setup
self._open_error_result.is_ready)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 395, in _flush_output
raise exceptions.ConnectionClosed()
pika.exceptions.ConnectionClosed
>>>
I am not sure what's the issue within the containers. I am using ubuntu:15.10 image for this. Any feedback on this would be really helpful.
It looks like the rabbitmq-server process was not running. Since its a container, no other process would be running by default than the ones specified in entrypoint. Once I started rabbitmq-server, it started working fine.
root@d3d44e2656a9# /etc/init.d/rabbitmq-server start
All I need to do now is to make sure that in my entrypoint, I am starting the rabbitmq-server process first and then starting the dependent services. This should apply to anything deployed inside a container.