This Python script monitors Docker resources (containers, images, volumes, networks) and sends notifications when changes are detected. It supports various messaging services.
- Monitors Docker resources:
- Containers (running, stopped, created, unhealthy, etc.)
- Images (pulled, removed, unused)
- Volumes and Networks (created, removed, unused)
- Real-time notifications with support for multiple accounts via:
- Telegram
- Discord
- Slack
- Gotify
- Ntfy
- Pushbullet
- Pushover
- Rocket.chat
- Matrix
- Mattermost
- Customizable polling interval through a configuration file (
config.json
). - Periodic checks with Docker resource updates logged and reported.
- Python 3.x
- Docker installed and running
- Dependencies:
docker
,requests
,schedule
git clone https://github.com/2boom-ua/dockcheck.git
cd dockcheck
pip install -r requirements.txt
A config.json file in the same directory as the script, and include your API tokens and configuration settings.
{
"TELEGRAM": {
"ON": false,
"TOKENS": [
"first tocken",
"second tocken",
"...."
],
"CHAT_IDS": [
"first chat_id",
"second chat_id",
"...."
]
},
"DISCORD": {
"ON": false,
"WEBHOOK_URLS": [
"first url",
"second url",
"...."
]
},
"SLACK": {
"ON": false,
"TOKENS": [
"first tocken",
"second tocken",
"...."
]
},
"GOTIFY": {
"ON": false,
"TOKENS": [
"first tocken",
"second tocken",
"...."
],
"CHAT_URLS": [
"first server_url",
"second server_url",
"...."
]
},
"NTFY": {
"ON": false,
"TOKENS": [
"first tocken",
"second tocken",
"...."
],
"CHAT_URLS": [
"first server_url",
"second server_url",
"...."
]
},
"PUSHBULLET": {
"ON": false,
"TOKENS": [
"first tocken",
"second tocken",
"...."
]
},
"PUSHOVER": {
"ON": false,
"TOKENS": [
"first tocken",
"second tocken",
"...."
],
"USER_KEYS": [
"first user_key",
"second user_key",
"...."
]
},
"MATRIX": {
"ON": false,
"TOKENS": [
"first tocken",
"second tocken",
"...."
],
"SERVER_URLS": [
"first server_url",
"second server_url",
"...."
],
"ROOM_IDS": [
"!first room_id",
"!second room_id",
"...."
]
},
"MATTERMOST": {
"ON": false,
"CHAT_URLS": [
"first server_url",
"second server_url",
"...."
]
},
"ROCKET": {
"ON": false,
"TOKENS": [
"first tocken",
"second tocken",
"...."
],
"USER_IDS": [
"first user_id",
"second user_id",
"...."
],
"SERVER_URLS": [
"first server_url",
"second server_url",
"...."
],
"CHANNELS": [
"#first channel",
"#second channel",
"...."
]
},
"DEFAULT_DOT_STYLE": true,
"SEC_REPEAT": 10
}
You can set this script to run as a Linux service for continuous monitoring.
Create a systemd service file:
nano /etc/systemd/system/dockcheck.service
Add the following content:
[Unit]
Description=docker state change monitor
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/bin/python3 /opt/dockcheck/dockcheck.py
[Install]
WantedBy=multi-user.target
Start and enable the service:
systemctl daemon-reload
systemctl enable dockcheck.service
systemctl start dockcheck.service
This project is licensed under the MIT License - see the MIT License for details.
- 2boom - GitHub