I have a .gitlab-ci.yml
file:
integration_test:
services:
- name: registry.gitlab.com/group/project/testmailserver:1.1
alias: \"mail.ema
From the official documentation:
The
services
keyword defines just another Docker image that is run during your job and is linked to the Docker image that theimage
keyword defines. This allows you to access the service image during build time.
There is no image
keyword in your .gitlab-ci.yml
file. Therefore, it's actually unpredictable where your job integration_test
runs.
If your job runs inside a Docker container, this container is linked to the container of your service. Links are a legacy feature of Docker, but it's quite similar to two containers that are connected via a separate network. This is quite similar to multiple services in one compose file that communicate with each other.
Everything that is executed in your job's container can access your service via its name or alias (mail.email
). Have a look at the Dockerfile of you mail server to see which ports the service listens to:
EXPOSE 25 587 143 465 993 110 995 4190
There is no need to manually expose any ports here. The ports
keyword in your compose file exposes ports of a container to your host system. If you do something similar in your CI pipeline, it will expose the ports to the system that runs the job. This is certainly not what you want.
In short: use something like mail.email:993
to connect to your mail server via IMAP from within your CI job.