Docker Watchdog is a simple Go
application that is used for detects all stopped containers that have exited
, paused
, or dead
state/status.
It uses list containers endpoints from
Docker Engine API.
The watcher will gather all docker containers information repeatedly every 3 seconds using go Ticker
function.
If there are stopped containers detected in our system or cloud infrastructure, Docker Watchdog
will send an email alert to Developer or System Administrator.
- Go Version:
go1.17.2 linux/amd64
- Docker Engine:
20.10+
Note: The installation only tested on Linux-Like operating system (linux distro), but you can even use docker-watchdog
by building it from the go source code for Windows and MacOS support.
- Clone this repository
$ git clone https://github.com/itsgitz/docker-watchdog.git
- Use
make install
command in the root project directory:
$ cd docker-watchdog
$ sudo make install
- After installation, the
docker-watchdog
application will run as linux service. But, we have to specify configuration value on/opt/.docker-watchdog.yaml
- For configuration example you can see on example/conf/.docker-watchdog.yaml
- Use
go build
command
$ go build
- The default executable output named
docker-watchdog
- If you installing
docker-watchdog
withmake
command, the application will run automatically assystemd
service or Linux service. - Docker Watchdog creates the default configuration file on
/opt/
directory called.docker-watchdog.yaml
. It's strongly recommend to edit the configuration file on/opt/.docker-watchdog.yaml
before run thedocker-watchdog
service. - After you specify the configuration value on configuration file, you have to restart the
docker-watchdog
service.
$ sudo systemctl restart docker-watchdog
- Make sure that the configuration value is correct. See example configuration
- If you run the
docker-watchdog
on MacOS or Windows, make sure to specify your own configuration file with option--config
# MacOS
$ ./docker-watchdog run --config my-docker-watchdog.yaml
# Windows
> docker-watchdog.exe run --config my-docker-watchdog.yaml
- You can even run the same command on Linux if you build the
docker-watchdog
from source code (withgo
)
If you use Gmail, you have to allow Less Secure App on security setting (Google Manage Account > Security > Less secure app access
)
- Email:
- Docker Watchdog Service
- Finish installation script for linux
- Add notification using Telegram Bot
Anggit M Ginanjar anggit.ginanjar.dev@gmail.com