docker-rabbitmq-example
docker-rabbitmq-example copied to clipboard
on "docker-compose up" getting errors on both consumer and publisher
Hi, looks like a very detailed and great example. But on taking the TL;DR route -> docker-compose up
both consumer and publisher fail to start with these errors:
Traceback (most recent call last):
File "/usr/src/app/publisher.py", line 37, in <module>
import pika
File "/usr/local/lib/python2.7/site-packages/pika/__init__.py", line 10, in <module>
from pika.connection import ConnectionParameters
File "/usr/local/lib/python2.7/site-packages/pika/connection.py", line 15, in <module>
import pika.callback
File "/usr/local/lib/python2.7/site-packages/pika/callback.py", line 8, in <module>
from pika import frame
File "/usr/local/lib/python2.7/site-packages/pika/frame.py", line 7, in <module>
from pika import spec
File "/usr/local/lib/python2.7/site-packages/pika/spec.py", line 18, in <module>
from pika.exchange_type import ExchangeType
File "/usr/local/lib/python2.7/site-packages/pika/exchange_type.py", line 1, in <module>
from enum import Enum
ImportError: No module named enum
cheers.
change in dockerfiles the python version for python:rc-alpine3.13
# Dockerfile for the publisher application.
#
# 'docker-compose build' from the parent directory will build this.
# 'docker-compose up' will too, if it needs to be.
#
# To build this by hand, cd into the "publisher" directory and run
# 'docker build -t publisher .', and then you can manually run
# 'docker run --rm -e AMQP_URL=... publisher' to run it.
# This is based on the Python 2.7 Alpine Linux image. See
# https://hub.docker.com/_/python/ for details on this image.
FROM python:rc-alpine3.13
# Our requirements are minimal, but it's good practice to install them
# first. Put things that change less often towards the top of the
# Dockerfile. Then if you need to rebuild the images, Docker will
# start running partway through the Dockerfile and skip over the steps
# where nothing's changed.
RUN pip install pika
# Without this setting, Python never prints anything out.
ENV PYTHONUNBUFFERED=1
# Actually install the application
WORKDIR /usr/src/app
# It's only a single file. It has to be in the same directory as the
# Dockerfile, or a subdirectory, but not a parent or sibling.
COPY publisher.py .
# When you just 'docker run publisher' with no command afterwards,
# default to this:
CMD ["python", "/usr/src/app/publisher.py"]
Thanks for your prompt response. I already moved on with more advanced implementation but surely other novices like me will earn from your help here. Cheers.
Alon
On Wed, Mar 17, 2021, 21:25 Miguel Rodriguez @.***> wrote:
change in dockerfiles the python version for python:rc-alpine3.13
Dockerfile for the publisher application.## 'docker-compose build' from the parent directory will build this.# 'docker-compose up' will too, if it needs to be.## To build this by hand, cd into the "publisher" directory and run# 'docker build -t publisher .', and then you can manually run# 'docker run --rm -e AMQP_URL=... publisher' to run it.
This is based on the Python 2.7 Alpine Linux image. See# https://hub.docker.com/_/python/ for details on this image.FROM python:rc-alpine3.13
Our requirements are minimal, but it's good practice to install them# first. Put things that change less often towards the top of the# Dockerfile. Then if you need to rebuild the images, Docker will# start running partway through the Dockerfile and skip over the steps# where nothing's changed.RUN pip install pika
Without this setting, Python never prints anything out.ENV PYTHONUNBUFFERED=1
Actually install the applicationWORKDIR /usr/src/app# It's only a single file. It has to be in the same directory as the# Dockerfile, or a subdirectory, but not a parent or sibling.COPY publisher.py .
When you just 'docker run publisher' with no command afterwards,# default to this:CMD ["python", "/usr/src/app/publisher.py"]
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dmaze/docker-rabbitmq-example/issues/2#issuecomment-801349223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAX57UA2SOBMSZGIY2CRIV3TED6ZVANCNFSM4ZKVWP2Q .