rabbitMQ nodedown error from Dockerfile

931 views Asked by At

When building this Dockerfile, when it gets to the command:

rabbitmqctl status

It Returns:

Error: unable to connect to node rabbit@d3659c5e113e: nodedown

DIAGNOSTICS
===========

nodes in question: [rabbit@d3659c5e113e]

hosts, their running nodes and ports:
- d3659c5e113e: [{rabbitmqctl20,52855}]

current node details:
- node name: rabbitmqctl20@d3659c5e113e

I have no idea where to go from here.

This is the Docker file I am using:

FROM ubuntu
MAINTAINER Will Mayger
RUN echo "deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -sc) main universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y tar git curl nano wget dialog net-tools build-essential
RUN apt-get install -y python python-dev python-distribute python-pip
RUN wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
RUN apt-key add rabbitmq-signing-key-public.asc
RUN sudo apt-get -y install rabbitmq-server
RUN sudo rabbitmqctl status
RUN sudo rabbitmqctl add_user test testpass1
RUN sudo rabbitmqctl add_vhost myvhost
RUN sudo rabbitmqctl set_permissions -p myvhost test ".*" ".*" ".*"
RUN sudo rabbitmq-server
RUN git clone https://github.com/CanopyCloud/microservice-python
RUN pip install -r /microservice-python/requirements.txt
EXPOSE 80
WORKDIR /microservice-python/

CMD python /microservice-python/server.py
1

There are 1 answers

0
creack On

It is because the rabitmq server is not running.

Docker works at the process level. Each line of your Dockerfile is isolated and will run only what you ask. So when you run rabbitmqctl status, it says node down because there is no other process running in the container.

If you do something like this, it works:

RUN rabbitmq-server& sleep 1 && rabbitmqctl status

Side note: you don't need sudo. You are already root.

Also, you probably should reuse the official image, even if you need custom changes. It is a good base to start: https://registry.hub.docker.com/_/rabbitmq/