0

I cant get the rabbitmqadmin to work in my rabbitmq docker.

I have this Dockerfile:

FROM rabbitmq:3-management

RUN apt-get update && apt-get install -y python

ADD rabbitmqadmin /usr/local/bin/rabbitmqadmin
ADD rabbitconf.json /rabbitconf.json

RUN chmod 755 /usr/local/bin/rabbitmqadmin

CMD ["/usr/local/bin/rabbitmqadmin -q import /rabbitconf.json"]

Build it like this:

docker build --tag=myrabbit .

Run it like this:

docker run -d -p 8080:15672 myrabbit

It does not work... The log shows:

/docker-entrypoint.sh: line 8: /usr/local/bin/rabbitmqadmin -q import     /rabbitconf.json: No such file or directory

What am I doing wrong ?

BR

user3594184
  • 805
  • 2
  • 9
  • 15

1 Answers1

1

You've mixed up the shell and exec formats for the CMD instruction.

CMD /usr/local/bin/rabbitmqadmin -q import /rabbitconf.json

Should work.

For more information see http://docs.docker.com/reference/builder/#cmd.

I'll leave the following for anyone else debugging similar problems:

The parent image rabbitmq:3-management is declares an ENTRYPOINT which runs the docker-entrypoint.sh script. Your CMD instruction is passed to this ENTRYPOINT script as an argument. Somewhere in the script, things go wrong.

Without seeing the script, we can't really debug the problem. However, one workaround would be to override the ENTRYPOINT instruction either in your Dockerfile or on the command line. For example, what happens if you run:

docker run -d -p 8080:15672 --entrypoint="" myrabbit

Note that this isn't the correct solution; you should try to use the ENTRYPOINT script of the parent image, or fix it so that it does what you want.

Adrian Mouat
  • 44,585
  • 16
  • 110
  • 102
  • Hi Adrian thanks for your answer. I have tried your suggestion and I get the same error. The rabbitmq:3-management is the official image from rabbitmq and the entrypoint.sh is: `#!/bin/bash set -e if [ "$1" = 'rabbitmq-server' ]; then chown -R rabbitmq /var/lib/rabbitmq fi exec "$@" ` The Dockerfile is here (https://github.com/docker-library/rabbitmq/blob/46b8c75905e6666eb737c17a5d813cf41efbe4f7/Dockerfile) I have also tried to change the CMD to this but the same error: ´CMD ["/rabbitmqadmin", "-q", "import", "/rabbitconf.json"]´ Am I thinking this wrong? Is this possible ? – user3594184 Mar 22 '15 at 12:59
  • Ok, just debug it from a shell: `docker run -it myrabbit /bin/bash` then try running `/usr/local/bin/rabbitmqadmin -q import /rabbitconf.json` and check you have the syntax correct and the files are accessible. – Adrian Mouat Mar 22 '15 at 13:38
  • Ah, I think you've just got the CMD syntax wrong; try removing the square brackets – Adrian Mouat Mar 22 '15 at 14:06
  • Hi that kinda worked... now I get: *** Could not connect: [Errno 111] Connection refused thats because the server is not started, in the rabbitmq:3-management Dockerfile there is a CMD and from the docker documentation there can only be one CMD, If you list more than one CMD then only the last CMD will take effect. – user3594184 Mar 22 '15 at 14:54
  • Yup, that's a completely different problem. You now need to use something like supervisord to start both your processes. – Adrian Mouat Mar 22 '15 at 15:00
  • I tried to make a run.sh script and put that in the CMD. the run cript contained: `#!/bin/bash rabbitmq-server & wait ./rabbitmqadmin import /rabbitconf.json ` This did not work either – user3594184 Mar 22 '15 at 15:01
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/73520/discussion-between-user3594184-and-adrian-mouat). – user3594184 Mar 22 '15 at 15:01