Monitoring the health and status of Docker containers is crucial for maintaining a reliable and efficient environment. Monocker is a lightweight tool designed to address this need by monitoring Docker container state changes and sending real-time alerts through various messaging platforms.
What is Monocker?
Monocker, short for “MONitors dOCKER,” is an open-source application that keeps track of Docker container states and notifies users of any changes. Whether a container transitions to paused, exited, unhealthy, or dead states, Monocker ensures you’re promptly informed, enabling swift action to maintain system stability.
Key Features
- Comprehensive Monitoring: Tracks state changes across all Docker containers, ensuring no event goes unnoticed.
- Customizable Alerts: Supports multiple messaging platforms, including Telegram, Pushbullet, Pushover, Discord, Ntfy, Slack, Gotify, Matrix, and Apprise, allowing users to choose their preferred notification method.
- Selective Monitoring: Offers options to include or exclude specific containers from monitoring, and to alert only on particular state changes, reducing unnecessary notifications.
- Health Checks: Incorporates built-in Docker health checks to provide insights into container health status.
Getting Started with Monocker
Deploying Monocker is straightforward, especially with Docker Compose. Here’s a sample configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
version: '2.4' services: monocker: container_name: monocker image: petersem/monocker environment: SERVER_LABEL: 'YourServerName' # Optional label to identify the server MESSAGE_PLATFORM: 'telegram@your_bot_id@your_chat_id' # Replace with your details # Other platforms: # MESSAGE_PLATFORM: 'pushbullet@your_api_key@your_device_id' # MESSAGE_PLATFORM: 'pushover@your_user_key@your_app_api_token' # MESSAGE_PLATFORM: 'discord@webhook_url' LABEL_ENABLE: 'false' # Set to 'true' to monitor specific containers ONLY_OFFLINE_STATES: 'false' # Set to 'true' to alert only on offline states EXCLUDE_EXITED: 'false' # Set to 'true' to ignore 'exited' state changes PERIOD: 10 # Polling period in seconds DISABLE_STARTUP_MSG: 'false' # Set to 'true' to suppress startup messages volumes: - /var/run/docker.sock:/var/run/docker.sock:ro restart: unless-stopped |
This configuration connects Monocker to the Docker socket, enabling it to monitor container states. Ensure you replace the MESSAGE_PLATFORM variable with your specific credentials. For detailed setup instructions and additional configuration options, refer to the Monocker GitHub repository.
Why Use Monocker?
In environments where uptime and reliability are paramount, being aware of container state changes is essential. Monocker provides a simple yet effective solution to stay informed about your Docker containers’ statuses, allowing for proactive management and quick resolution of potential issues.
By integrating Monocker into your monitoring toolkit, you can enhance your system’s resilience and ensure that critical services remain operational.