title: Docker, connection refused for every other running services
body: <p>My local installation of docker cannot access to other ports.</p>
  
  <p>This is my <code>docker-compose.yml</code> file:</p>
  
  <pre><code>db:
    image: library/mysql:5.6
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
    expose:
      - "3306"
    ports:
      - "3306:3306"
  
  mailcatcher:
    image: yappabe/mailcatcher
    ports:
      - "1025:1025"
      - "1080:1080"
  
  rails-app:
    build: .
    dockerfile: "Dockerfile"
    environment:
      RAILS_ENV: development
    links:
      - mailcatcher
      - db
    command: bundle exec rails server -p 3005 -b '0.0.0.0'
    volumes:
      - ".:/home/app"
    volumes_from:
      - bundle
    expose:
      - "3005"
    ports:
      - "3005:3005"
  </code></pre>
  
  <p>This is the config for mailcatcher <code>config/environments/development.rb</code>:</p>
  
  <pre><code>config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
  </code></pre>
  
  <p>This is how I run the rails app:</p>
  
  <pre><code>docker-compose run --service-ports rails-app
  </code></pre>
  
  <p>This is what I see when running <code>docker ps</code>:</p>
  
  <pre><code>&gt; docker ps
  CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                                            NAMES
  1fa8ac2ad8fd        pmt_rails-app          "bundle exec rails se"   5 seconds ago       Up 3 seconds        0.0.0.0:3005-&gt;3005/tcp                           pmt_rails-app_run_1
  4f65bb2fc9ac        yappabe/mailcatcher    "/run.sh"                About an hour ago   Up About an hour    0.0.0.0:1025-&gt;1025/tcp, 0.0.0.0:1080-&gt;1080/tcp   pmt_mailcatcher_1
  cfb364ee569f        library/mysql:5.6      "docker-entrypoint.sh"   About an hour ago   Up About an hour    0.0.0.0:3306-&gt;3306/tcp                           pmt_db_1
  </code></pre>
  
  <p>This is what I get when rails app tries to send an email:</p>
  
  <pre><code>Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 1025
  from /usr/local/lib/ruby/2.3.0/net/smtp.rb:542:in `initialize'
  </code></pre>
  
  <p>I get the same error when I try to connect with another <code>rails server</code> that is running in another port.</p>
  
  <p>I am working with Docker-beta in a Mac OSX.</p>