3

I am using the latest version of boot2docker version 1.3.2, 495c19a on a windows 7 (SP1) 64 bit machine.

My docker container is running a celery process which attempts to connect to a rabbitMQ service running on the same machine that boot2docker is running on.

The Celery process running within the docker container cannot connect to RabbitMQ and reports the following :

[2014-12-02 10:28:41,141: ERROR/MainProcess] consumer: Cannot connect to amqp:// guest:**@127.0.0.1:5672//: [Errno 111] Connection refused. Trying again in 2.00 seconds...

I have reason to believe this is a network related issue, associated with routing from the container, to the VirtualBox host, and from the host to the RabbitMQ service running on the local machine; I do not know how to configure this and I was wondering if anyone can advise me how to proceed?

I tried setting up port 5672 in port forwarding but it didn't work (but I believe this is for incoming traffic to the VM, like boot2docker ssh).

I am running the container as docker run -i -t tagname

I am not specifying a host with -h when I run the container.

I'm sorry if this question appears rather clueless or if the answer appears obvious ... I appreciate any help!


Some additional information :

The routing table of the host VM is what boot2docker configured during installation as follows :

enter image description here

  • docker0 IP Address is 172.17.42.1

  • eth0 IP Address is 10.0.2.15

  • eth1 IP Address is 192.168.59.103

  • eth0 is attached to NAT (Adapter 1) in the VirtualBox VM network configuration.

  • Adapter 1 has port forwarding setup for ssh; default setting of host IP 127.0.0.1, host port 2022, guest port 22.

  • eth1 is attached to Host-only adapter (Adapter 2).

  • Both adapters are set to promiscuous mode (allow all).

  • The IP Address of the docker container is 172.17.0.33.

2
  • Rabbit is running on the Windows host or on the VirtualBox Linux guest?
    – Bryan
    Dec 2, 2014 at 12:03
  • RabbitMQ service is running on the Windows host.
    – d3monster
    Dec 3, 2014 at 0:47

3 Answers 3

2

[2014-12-02 10:28:41,141: ERROR/MainProcess] consumer: Cannot connect to amqp:// guest:**@127.0.0.1:5672//: [Errno 111] Connection refused. Trying again in 2.00 seconds...

127.0.0.1 is a special IP address that means "me", and inside the container it means "me the container", so this is why it is not connecting to the outer host. So the first thing to do is change the IP address where you are trying to connect to Rabbit to that of the outer host where it is running.

Then you probably have to do something about routing, but let's take one step at a time.

2
  • Thank you Bryan, your suggestion was a solution to my problem. I set the IP address that celery is connecting to the IP of the windows host that RabbitMQ service is running on. It's working and I am really glad you could help me get up and running so quickly! I was wondering if there is something I can do with the VirtualBox networking to route the traffic from celery runnning in container, to the virtualbox VM, and on to the windows host instead of setting the windows host IP for celery directly.
    – d3monster
    Dec 3, 2014 at 11:43
  • Not quite sure about "instead of setting the windows host IP" - if that's where Rabbit is running then that's the IP address you need to use. However, for info about routing I found this article quite useful: ispyker.blogspot.co.uk/2014/04/… - it's written for OSX but most of the VirtualBox config will be very similar on PC.
    – Bryan
    Dec 3, 2014 at 12:13
2

as your RabbitMQ server is running on your Windows host, you need to tell your container that it should talk to that IP - which would probably be 192.168.59.3

most importantly, your container's 127.0.0.1 is only a loopback device to that container's services - not even the boot2docker vm's ports.

You could set up an ambassador container that has --expose=80 and uses something like socat to forward all traffic from that container to your host (see svendowideit/ambassador). Then you'd --link that ambassador container to your current image

but personally, I'd avoid that initially, and just configure your containerised app to talk to the real host's IP

1
  • Thank you Bryan and SvenDowideit,
    – d3monster
    Dec 3, 2014 at 11:30
0

You have to specifc explicitely ports for port redirection separately for boot2docker and docker.

Please try this:

c:\>boot2docker init
c:\>boot2docker up
c:\>boot2docker ssh -L 0.0.0.0:5672:localhost:5672
docker@boot2docker:~$ docker run -it -p 5672:5672 tagname
1
  • hi Magic Wand, thanks for your response! Unfortunately that doesn't work because the port is being used by RabbitMQ service. The following error is reported: bind: Not owner channel_setup_fwd_listener: cannot listen to port: 5672 Could not request local forwarding. If I stop the rabbitMQ service then the port binding reports no error.
    – d3monster
    Dec 3, 2014 at 0:46

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.