Why do I need a Mail Transport Agent to run Gitlab Docker?

At this moment I’m running a Gitlab server (Omnibus installation) but I am considering to run Gitlab to a Docker container, I think could be better especially to reduce downtime upgrading to newer version, as we know, Gitlab release a new version very often. Please, let me know your thoughts about it.

Reading documentation I found this paragraph:

The Docker images don’t include a mail transport agent (MTA). The recommended solution is to add an MTA (such as Postfix or Sendmail) running in a separate container. As another option, you can install an MTA directly in the GitLab container, but this adds maintenance overhead as you’ll likely need to reinstall the MTA after every upgrade or restart.

What is the exact meaning of this?? I coud not find in my gitlab.rb file any configuration referencing to an MTA. Please, can you help me to understand this?? I need to know if I will need to run a second container with MTA to have my Gitlab as it is working now.

Thank you.

MTA or SMTP Server if you like for sending emails when new users are created, or when issues are updated, other changes. Do you need it? No not really, if you aren’t bothered about getting email updates when things change.

You don’t need a second container because you can configure Gitlab to connect to an account like gmail. See the docs: SMTP settings | GitLab

2 Likes

Unless you need to run your own mail server, you don’t need to run your own MTA.

I’ve been running gitlab in a docker container without an MTA for over 5 years now. We simply connect directly to SMTP server of our email provider.

The configuration is simple, my docker-compose.yml file looks like this:

web:
  image: 'gitlab/gitlab-ee:17.1.1-ee.0'
  restart: always
  hostname: docker-gitlab.<redacted>
  shm_size: 256m
  environment:
    GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://gitlab.<redacted>'
        letsencrypt['enable'] = false
        nginx['listen_port'] = 80
        nginx['listen_https'] = false
        ...
        gitlab_rails['smtp_enable'] = true
        gitlab_rails['smtp_address'] = '<redacted>'
        gitlab_rails['smtp_port'] = 465
        gitlab_rails['smtp_user_name'] = '<redacted>'
        gitlab_rails['smtp_password'] = '<redacted>'
        gitlab_rails['smtp_domain'] = '<redacted>'
        gitlab_rails['smtp_authentication'] = "login"
        gitlab_rails['smtp_tls'] = true
        gitlab_rails['gitlab_email_from'] = '<redacted>'
        gitlab_rails['gitlab_email_reply_to'] = 'noreply@<redacted>'
2 Likes

Currently, Gitlab is sending messages, I can remember now this cases:

  • when a new user is created
  • when I login from diferent computer
  • when adding new ssh-keys

My current configuration in /etc/gitlab/gitlab.rb wich is an Omnibus installation the only setting about sending messages is:

`gitlab_rails['gitlab_email_from'] = 'gitlab@mycompany.com'
`

But nothing about SMTP, those settings are commented. I think that since the installation is Omnibus, it is using an MTA from the server.

I would like to keep this functionality when I move Gitlab to Docker. I think that when I run Gitlab in Docker container I will need to set up SMTP settings with my company SMTP server, is this correct?

Most likely on your Gitlab omnibus server you have perhaps postfix/sendmail/exim or something installed (check for something running on port 25) by using:

netstat -tunlp

or if netstat isn’t installed, then:

ss -tunlp

I do similar with mine, I have all SMTP settings commented in gitlab.rb, so it will be using what’s on the server.

Since the Gitlab docker container doesn’t have SMTP, you will have to see if it will work when postfix/sendmail/exim4 is installed on the docker server, or whether you will need to configure Gitlab as @shaoran1 suggested as per his docker config. I don’t use Gitlab with docker, so cannot help with that.

Thank you @iwalker , you are right, one process is running in port 25, this guy is sending mails for Gitlab.

Thanks for your comments @iwalker and @shaoran1 .

1 Like

If your sever is running a local MTA on port 25, then you can use host.docker.internal to access the IP address of your host inside the container (see Explore networking features on Docker Desktop | Docker Docs). See also linux - Forward host port to docker container - Stack Overflow

1 Like