Get notified when your Docker containers are unhealthy.
All configuration is done via environment variables, see the table below for all options and default values. Only CONTAINERMON_NOTIFICATION_URL is mandatory, all other fields are optional. |
Name | Type | Default Value | Description | |
---|---|---|---|---|---|
CONTAINERMON_FAIL_LIMIT | Int | 1 | Number of consecutive 'unhealthy' checks to reach before sending a notification | ||
CONTAINERMON_CRON | String | /5 * | Standard Cron schedule of when to run healthchecks | ||
CONTAINERMON_NOTIFICATION_URL | String | N/A | Notification URL for Shoutrrr. Multiple services can be used with the \| (pipe) character as a separator. |
||
CONTAINERMON_USE_LABELS | Bool | false | If true will only monitor containers with the label containermon.enable=true set |
||
CONTAINERMON_NOTIFY_HEALTHY | Bool | true | If true will send a notification when an 'unhealthy' container returns to being 'healthy' |
||
CONTAINERMON_CHECK_STOPPED | Bool | true | If true will consider stopped containers as 'unhealthy'. If false , you will only be notified for containers that have a healthcheck set |
||
CONTAINERMON_MESSAGE_PREFIX | String | N/A | Custom text to be prefixed to all notification messages. | ||
DOCKER_HOST | String | /var/run/docker.sock | Path for the Docker API socket | ||
DOCKER_API_VERSION | String | docker default | Docker API version to use | ||
DOCKER_CERT_PATH | String | docker default | Path to load the TLS certificates from | ||
DOCKER_TLS_VERIFY | Bool | false | Enable or disable TLS verification |
go run app.go
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-e CONTAINERMON_NOTIFICATION_URL=telegram://token@telegram?channels=channel-1 \
ghcr.io/rafhaanshah/container-mon:latest
version: "3.8"
services:
container-mon:
container_name: container-mon
image: ghcr.io/rafhaanshah/container-mon:latest
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- CONTAINERMON_NOTIFICATION_URL=telegram://token@telegram?channels=channel-1
client version 1.43 is too new. Maximum supported API version is 1.42
then please set the DOCKER_API_VERSION
environment variable to the latest version supported by your Docker engine (e.g. DOCKER_API_VERSION=1.42
, which you can check by running docker version
.docker run \
-e DOCKER_HOST=tcp://socket-proxy:2375
...
root
by default to access the Docker socket. You may run it as another user that has access to the socket as described here: Running a Docker container as a non-root user ->
docker run \
-u $(id -u):$(stat -c '%g' "/var/run/docker.sock") \
...