pika.exceptions.AMQPConnectionError

138 views
Skip to first unread message

Naiara Maneiro

unread,
Nov 20, 2020, 7:34:07 AM11/20/20
to rabbitmq-users

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.

Reply all
Reply to author
Forward
0 new messages