Docker Compose - container receiving connection refused
<p>Using docker-compose, I'm trying to run my API on a publicly available port 8080 and an sqs service on a privately available port 9324. The API needs to be able to communicate with the sqs service. In order to do so, I have set up the following docker-compose.yml:</p>

<pre><code>version: '2'
services:
  api:
    image: api
    ports:
      - "8080:8080"
  sqs:
    image: pakohan/elasticmq
</code></pre>

<p>I have tried several iterations, including adding a link alias for the api:</p>

<pre><code>links:
  - "sqs:localhost"
</code></pre>

<p>and exposing the port for sqs:</p>

<pre><code>ports:
  - "9324:9324"
</code></pre>

<p>but neither seems to work. The API always gets a connection refused error when trying to communicate with the sqs service. </p>

<p>When the sqs port is publicly exposed an API running outside of docker is able to communicate just fine (so the sqs service is getting initialized properly).</p>

<p>Does anyone have any ideas as to how to solve this problem?</p>