Connecting to rabbitmq docker container from service in another container
<p>I've done a lot of searching  but I cannot fix this issue. </p>

<p>I have a basic Rabbitmq container running via this command:</p>

<p><code>docker run -d --hostname rabbitmqhost --name rabbitmq -p 15672:15672 -p 5672:5672 rabbitmq:3-management</code></p>

<p>I am using <code>nameko</code> to create a microservice which connects to this container. Here's a basic microservice module <code>main.py</code>:</p>

<pre><code>from nameko.rpc import rpc
class Service_Name(object):
    name = "service_name"

    @rpc
    def service_endpoint(self, arg=None):
        logging.info('service_one endpoint, arg = %s', arg)
</code></pre>

<p>This service runs and connects to the rabbitmq from my host machine with the command: </p>

<p><code>nameko run main --broker amqp://guest:guest@localhost</code></p>

<p>I wanted to put the service into a Docker container (called <code>service_one</code>) but when I do so and run the previous nameko command I get <code>socket.error: [Errno 111] ECONNREFUSED</code> no matter how I try and link the two containers.</p>

<p>What would be the correct method? The aim is to have each service in a container, all talking to each other through rabbit. Thanks.</p>