Can't get notifications to work in icinga docker

I am very new to Icinga and have struggled to get where I am by following online guides. I have successfully setup all my hosts and services but I am now struggling with notifications. I followed this to get Icinga up and running (Icinga Docker Setup Made Easy with Docker Compose | Tutorial). I think I have properly set everything up for a notification for both hosts and services but when I try to apply the notification to a host or service, I get this error:

[2026-02-07 11:47:58 +0000] information/cli: Icinga application loader (version: v2.15.1)
[2026-02-07 11:47:58 +0000] information/cli: Loading configuration file(s).
[2026-02-07 11:47:58 +0000] information/ConfigItem: Committing config item(s).
[2026-02-07 11:47:58 +0000] information/ApiListener: My API identity: Icinga2
[2026-02-07 11:47:58 +0000] critical/config: Error: Validation failed for object 'DesktopMasterBedroom!Notifications HOST' of type 'Notification'; Attribute 'command': Object 'mail-service-notification' of type 'NotificationCommand' does not exist.
Location: in [stage]/zones.d/master/notification_templates.conf: 2:5-2:41
[stage]/zones.d/master/notification_templates.conf(1): template Notification "HOST Notifications" {
[stage]/zones.d/master/notification_templates.conf(2):     command = "mail-service-notification"
                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[stage]/zones.d/master/notification_templates.conf(3):     period = "Always"
[stage]/zones.d/master/notification_templates.conf(4):     states = [ Down, Up ]

Any assistance would be greatly appreciated

Thanks

So I have made some progress today as I now see notifications being sent under history. This is what I did:

cd /etc/icinga2/zones.d
mkdir master
cd master
cp /etc/icinga2/conf.d/commands.conf /etc/icinga2/zones.d/master/commands.conf

Curious if this will persist docker starts and stops?

Now I am getting the error:

terminated with exit code 1, output: mail: cannot send message: Process exited with a non-zero status

I have Exim4 configured on the host and it works fine. I also have bsd-mailx installed as I think it installs with Exim4. mail, Mail, and mailx are all symlinked to /usr/bin/bsd-mailx

You probably don’t have a mailserver (exim) running in the container, do you?

You’ll need an SMTP forwarder instead. I usually use SSMTP for this in my docker containers.

Thank you for this response @adn77 as this is likely my issue. I have a couple questions if you could be so kind. 1) If install ssmtp inside the container, do I need to do anything to make the installation persist reboots of the host or restarts of the container 2) Do I configure ssmtp to forward mail to exim4 on the host or straight to the gmail smtp server

thanks

If you want the ICINGA2 container to send mail, you will already find MSMTP installed in the image:

To notify by e-mail, provide an msmtp configuration - either by mounting the /etc/msmtprc file or by specifying the desired content of ~icinga/.msmtprc via the environment variable MSMTPRC.

:slight_smile:

As to the second question, it depends on your local mail sending policy… I usually use a local smarthost in our network.

so, I created a docker volume

home/myuser/docker/docker-compose-icinga/.msmtprc:/etc/msmtprc/.msmtprc

created the .msmtprc file:

## Set default values for all following accounts.
#defaults
#auth           on
#tls            on
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
#logfile        ~/.msmtp.log

# Gmail
account        gmail
host           smtp.gmail.com
port           587
tls_starttls   on
from           user@gmail.com
user           user
password       app-password

## A freemail service
#account        freemail
#host           smtp.freemail.example
#from           joe_smith@freemail.example
#...

## Accounts can inherit info from another account
#account        postmasterfreemail : freemail
#from           postmaster*@freemail.example

# Set a default account
account default: gmail

then I try to send mail from inside the container using:
mail -s "Icinga Raspi 5 Test" gmailuser@gmail.com

and I get cannot send message: Process exited with a non-zero status

I wonder if I need to map port 587 in my docker-compose?

edit: that didn’t help, same error

I have mail working inside the container now. I can send mail using the mail -s "test" user@gmail.com. Icinga shows notification history indicating notifications are being generated but I still get the cannot send message: Process exited with a non-zero status inside the container when reviewing docker logs.

Posting my notification settings to see if anyone sees anything out of the ordinary

template User "generic-host-notifications" {
    enable_notifications = true
    states = [ Down, Up ]
    types = [
        DowntimeEnd,
        DowntimeStart,
        FlappingEnd,
        FlappingStart,
        Problem,
        Recovery
    ]
}

object User "user1" {
    import "generic-host-notifications"

    display_name = "User HOST"
    email = "user@gmail.com"
    period = "Always"
}

template Notification "HOST Notifications" {
    command = "mail-host-notification"
    period = "Always"
    states = [ Down, Up ]
    types = [ DowntimeEnd, DowntimeStart, FlappingEnd, FlappingStart ]
    users = [ "user1" ]
}

apply Notification "Notifications HOST" to Host {
    import "HOST Notifications"

    assign where host.vars.NodeType == "linux1" 
    states = [ Down, Up ]
    types = [
        DowntimeEnd,
        DowntimeRemoved,
        DowntimeStart,
        FlappingEnd,
        FlappingStart
    ]
    users = [ "user1" ]
}

object TimePeriod "Always" {
    import "legacy-timeperiod"
    display_name = "24x7"
    ranges = {
        "friday"	= "00:00-24:00"
        "monday"	= "00:00-24:00"
        "saturday"	= "00:00-24:00"
        "sunday"	= "00:00-24:00"
        "thursday"	= "00:00-24:00"
        "tuesday"	= "00:00-24:00"
        "wednesday"	= "00:00-24:00"
    }
}