Hello,
I'm new with RabbitMQ and pika, and I'm trying to recreate "Hello World" tutorial (
https://www.rabbitmq.com/tutorials/tutorial-one-python.html) with Dokerfile. Using both send.py and receive.py in the terminal, with
python send.py and
python receive.py works fine, but when I build my Dockerfile (sudo docker build -t naiaramaneiro/rabbitmq .) appears the following error:
Traceback (most recent call last):
File "send.py", line 3, in <module>
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 359, in __init__
self._impl = self._create_connection(parameters, _impl_class)
File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
raise self._reap_last_connection_workflow_error(error)
pika.exceptions.AMQPConnectionError
My Dockerfile:
#Imagen base
FROM rabbitmq:3.8
#Instalar dependencias
RUN apt-get -qq update && apt-get -qq -y install python
RUN apt-get -qq -y install python-pip && pip install pika
RUN apt-get -qq -y install rabbitmq-server
#Directorio de trabajo
WORKDIR /code
#Copiar ficheros
COPY send.py /code/
COPY receive.py /code/
#Exponer un puerto
EXPOSE 5672
RUN python send.py
Thank you.