title: How are Gitlab CI service ports exposed?
body: <p>I have a <code>.gitlab-ci.yml</code> file:</p>
  
  <pre><code>integration_test:
    services:
      - name: registry.gitlab.com/group/project/testmailserver:1.1
        alias: "mail.email"
    stage: test
    script:
      - ./gradlew -g /cache/.gradle --stacktrace --info integrationTest
  </code></pre>
  
  <p>The service is a full stack email server based on this: <code>tvial/docker-mailserver:latest</code>. Locally with my <code>docker-compose</code> config I'm able to run it and connect to it.</p>
  
  <pre><code>version: '2'
  
  services:
    mail:
      image: registry.gitlab.com/group/project/testmailserver:1.1
      hostname: mail
      domainname: localhost
      ports:
        - "25:25"
        - "143:143"
        - "587:587"
        - "993:993"
      environment:
        - ONE_DIR=1
        - DMS_DEBUG=0
        - MAIL_USER=invoicereader
        - MAIL_PASS=invoicereader
      cap_add:
        - NET_ADMIN
  </code></pre>
  
  <p>If I run it with <code>docker-compose up</code> and connect to it via IMAP on port 993 it works fine. Also the integration test runs smoothly</p>
  
  <p>However, if the integration test is executed by gitlab CI, it fails. The only exception I could get is <em>Connection refused</em>.</p>
  
  <p>Can it be that the ports of the service are not exposed properly? How does the CI server determine the ports it has to open to said service?</p>
  
  <p>What might be the problem when running with CI? How can I test it differently?</p>
  
  <p>Sorry for the lot of questions, I'm just hopelessly lost..</p>