Keeps Docker resources in shape based on rules and usage
Project description
Docker Shaper
This is a spin-off package for the docker-shaper tool, which can be used to monitor Docker stuff
like containers, images and volumes and automatically enforce certain cleanup-rules.
Installation
[<PYTHON> -m] pip[3] install [--user] [--upgrade] docker-shaper
Usage
The tool will start an interactive terminal UI (TUI).
poetry run docker-shaper
Attach to build nodes
The application is running in a tmux on the build nodes. The following command can be used to attach to the session:
ssh -t <build node> "su jenkins -Pc 'tmux attach-session -t docker-shaper'"
Development & Contribution
Prerequisites
- Python 3.8.10+ (e.g. via
pyenv) poetryandpre-commitpython3 -m pip install --upgrade --user poetry pre-commit
git clone ssh://review.lan.tribe29.com:29418/docker_shaper
cd docker_shaper
pre-commit install
# if you need a specific version of Python inside your dev environment
poetry env use ~/.pyenv/versions/3.8.10/bin/python3
poetry install
Workflow
- (once and only for publishing to PyPi) Get token on PyPi.org
- (once and only for publishing to PyPi)
poetry config pypi-token.checkmk pypi-<LONG-STRING>(will write to~/.config/pypoetry/auth.toml) - modify and check commits via
pre-commit - after work is done locally:
- adapt version in
pyproject.tomlwith
- adapt version in
# see section Setup
# poetry self add poetry-bumpversion
poetry version [patch, minor, major] [--dry-run]
- update dependencies before/with a new release
poetry lock
- build and check package locally
poetry build && \
twine check dist/* &&
python3 -m pip uninstall -y docker_shaper && \
python3 -m pip install --user dist/docker_shaper-$(grep -E "^version.?=" pyproject.toml | cut -d '"' -f 2)-py3-none-any.whl
- commit, push, review and merge the changes, see
checkmk_dev_tools/+/88632/
git add ...
git commit -m "bump version, update dependencies"
# merge
- publish new package version
poetry publish --build [--repository docker_shaper]
git tag -a v<VERSION> <MERGE_COMMIT> -m "v<VERSION>"
Todo
-
Fix: stuck auto-reload: was: postpone=True + monitoring log
-
Fix: crawl-images should fix parents not having them listed
-
[-] Fix: stuck crawl images (too many async requests, does not happen in production)
-
Fix:
'677aff0727' could not be removed: DockerError(404, 'No such image: 677aff0727:latest') -
Fix:
tried to remove container 4f5fb0848c unknown to us -
Fix: Crashes (see runlog)
-
Image update message only if needed
-
New TUI
- make ongoing progress visible
-
review log levels (too verbose)
-
installable via
pip install -
Quart interface (instead of
flask) -
auto-apply changes to source and configuration files
-
outsourced config file
-
bring in features of former
dgcd -
bring in features of former
dockermon -
untag certain tags
-
container cleanup
-
Fix
noneimage lookup -
Exceptions to messages
-
Clip
-
Increase/decrease logging via web / signal
-
Link: cleanup (images/containers) now
-
Add volumes list (with recent owners)
-
Containers: Store CPU / Memory usage over time
-
Containers: store history
-
Persist messages
-
Remove old message/container logs
-
Show different color for unmatched images
-
Warn about use of unpinned / upstream images
-
Handle 'build cache objects' (found on system prune)
-
Bring in volume monitoring: which volumes have been created and used by which containers?
-
Containers: show total CPU usage
-
Containers: list volumes
-
Images: list parents / children
-
Volumes: list usage
-
Instructions to readme
-
List unmatched / overmatched tags
-
Links to
delete/remove -
Links to jobs
-
Link: inspect
-
Graph: cpu / containers (idle/up)
-
Authenticate (at least if we can modify behavior, like stopping/removing images/containers)
Knowledge
(just misc links to articles that helped me out)
- How to delete docker images from Nexus Repository 3
- Showing Text Box On Hover (In Table)
- Beautiful Interactive Tables for your Flask Templates
- https://github.com/torfsen/python-systemd-tutorial
- https://www.digitalocean.com/community/tutorials/how-to-use-templates-in-a-flask-application
- https://stackoverflow.com/questions/49957034/live-updating-dynamic-variable-on-html-with-flask
- https://pgjones.gitlab.io/quart/how_to_guides/templating.html
Logging
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docker_shaper-2.0.4.tar.gz.
File metadata
- Download URL: docker_shaper-2.0.4.tar.gz
- Upload date:
- Size: 34.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-50-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
258ebe1374f18910257bbec8f237c1123772fa7de2855394ec52700403bd1ab6
|
|
| MD5 |
529c0bd89caf78fa90bbf29c720831af
|
|
| BLAKE2b-256 |
7542ab09eca2dad31c332e29fce986c0a5df4760836625e985b235c0899918f8
|
File details
Details for the file docker_shaper-2.0.4-py3-none-any.whl.
File metadata
- Download URL: docker_shaper-2.0.4-py3-none-any.whl
- Upload date:
- Size: 36.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-50-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcc992e0fc2d5e5fe38528165f6fb03ae2d8d8ecc9545acbb9c6cacea935a1fb
|
|
| MD5 |
a43043ffae3a57bdc30748fa85b13ab0
|
|
| BLAKE2b-256 |
5bc48448f3cee9e7931f7719bb5ac321e4d53b784b7c89f78dec9a991ba7d600
|