Simple docker container monitor informing about non-running and unhealthy containers.
Checks the status of containers containing a given name. Reports containers that are not running (status is not running
) or running but their health status is unhealthy
. The health status is only reported if you are using HEALTHCHECK
.
Nothing will be reported if everything is fine to make it compatible with calling the script using a cronjob (cron
will not send out emails on empty output).
docker-monitor
makes use of the Docker SDK for Python to access information from the Docker Engine API.
You therefore need to install the docker
Python library. It is best to use a virtual environment, for example, using venv
:
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements/base.txt
python monitor.py --container-name <nameOfContainer>
Note that you could also use your existing system environment and just install the dependencies there, though that is generally not recommended.
To facilitate this task, you can use the helper script monitor.sh
that ensures monitor.py
is being called from the virtual environment.
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements/development.txt
Linting with flake8
and type checking with mypy
is used. The configuration is located in setup.cfg
. The project contains settings for vscode
where these are enabled. However, they can also be executed from the project root as follows.
- Linting with
flake8
: Executeflake8
- Static type checking with
mypy
: Executemypy
This project makes use of pip-upgrader to update the requirements files to the latest versions of dependencies.
- Run
pip-upgrade
to update the desired dependencies - Verify that everything still works
- Commit the updates to the requirements file(s)