Real time notification on Docker container status
Tags: boatswain, docker
Published: 2020-01-21 09:40:11

---
title: "Real time notification on Docker container status"
published: true
description: "Receive real time notification when your Docker container status is changed."
tags: [Boatswain, Docker]
cover_image: https://thepracticaldev.s3.amazonaws.com/i/4ym29u7d44t3ppu7mrl8.jpg
---

_Originally posted on [Boatswain Blog](https://blog.boatswain.io/post/real-time-notification-on-docker-container-status/)._

---

In the recent release of the [Boatswain][boatswain] web portal (version 0.1.6), we have implemented a simple real time notification mechanism on the Docker container status. We hope this is helpful to engineer responding quickly to any unexpected issue happen on their container.

## Setup the real time notification

Now, [Boatswain][boatswain] user could setup the real time notification on the **Notification Settings** page which in under the **Settings** menu on the top right hand corner.

![Notification Settings](https://thepracticaldev.s3.amazonaws.com/i/4ujrjkqxl3900mygtbrw.jpg)

### Enable the real time notification

Sometimes, not all the containers running on the [Docker][docker] server are our concerns. So we allow user to enable the notification feature selectively by using regular expression. Any containers with name matched with the regular expressions would have notification enabled.

Here are the two rules when setting up the regular expression:

1. Include the `/` before and after.
1. Only accepts the `i` flag.

![Configure the regular expression to enable notification](https://thepracticaldev.s3.amazonaws.com/i/wpk8wmoko5t8iczys431.jpg)

### Check out which container have notification enabled

Below the regular expression form, there is a list showing the containers which have notification enabled. Any detected containers in the recent 24 hours will be listed.

![List of notification enabled containers](https://thepracticaldev.s3.amazonaws.com/i/qgfsizw45e1fsni7e2kt.jpg)

Please note that the above list is just for reference and any newly added container would also have notification enabled as long as its name matched any regular expression.

### Receive the notification email

Whenever the container status is changed, the email address associated with the corresponding [Boatswain][boatswain] account would receive an notification email. Here is an example:

```
Hi ykyuen,

We have detected a status change of the following container:
---
Host:            camus
Container ID:    1d2ce3c96b372fc61622c0c0133efda6de24cd2fad2e8faab810b8539d3ce4a1
Container name:  nginx-test
Container image: nginx:latest
Command:         nginx -g 'daemon off;'
Status change:   running -> exited
Exit code:       0
Error:           
Is OOM killed:   No
---

- Boatswain Team
 ____              _                     _
|  _ \            | |                   (_)
| |_) | ___   __ _| |_ _____      ____ _ _ _ __
|  _ < / _ \ / _` | __/ __\ \ /\ / / _` | | '_ \
| |_) | (_) | (_| | |_\__ \\ V  V / (_| | | | | |
|____/ \___/ \__,_|\__|___/ \_/\_/ \__,_|_|_| |_|
```

## What's next?

We notice that [Boatswain][boatswain] consumes certain amount of server resources and user might hang back especially when his/her application is running on a small instance. So we are working on the Boatswain configuration and let user decide the frequency of the metrics and log collections.

Lastly, happy coding :man_technologist: and wishing all the best to all of you :confetti_ball: :rat: :tada:.





[boatswain]: https://boatswain.io/
[docker]: https://www.docker.com/