diff --git a/check_dockercontainer_info b/check_dockercontainer_info index f5a8c00da57c84c271dfa6b59ae921e9145fe237..e8d18007052b5f2741eb1c56e894ba7b374f290e 100755 --- a/check_dockercontainer_info +++ b/check_dockercontainer_info @@ -14,13 +14,14 @@ # 2024-01-18 v0.1 <axel.hahn@unibe.ch> init # 2024-02-13 v1.0 <axel.hahn@unibe.ch> update docker ps --format # 2025-02-10 v1.1 <axel.hahn@unibe.ch> harden sourcing files +# 2025-04-04 v1.2 <axel.hahn@unibe.ch> use sudo on all docker commands # ====================================================================== # shellcheck source=/dev/null . "$( dirname "$0" )/inc_pluginfunctions" || exit 1 . "$( dirname "$0" )/inc_dockerfunctions.sh" || exit 1 -self_APPVERSION=1.1 +self_APPVERSION=1.2 # ---------------------------------------------------------------------- # FUNCTIONS @@ -93,7 +94,7 @@ ph.require "jq" if ph.hasParamoption "s" "$@"; then echo "List of all containers (docker ps --all):" echo - docker ps --all + sudo -n --preserve-env docker ps --all echo exit 0 fi @@ -105,7 +106,7 @@ regex=$(ph.getValueWithParam '' f "$@") if [ -z "$id" ]; then if [ -n "$regex" ]; then - id=$( docker ps --all | grep -E "$regex" | head -1 | awk '{ print $1 }' ) + id=$( sudo -n --preserve-env docker ps --all | grep -E "$regex" | head -1 | awk '{ print $1 }' ) fi fi if [ -z "$id" ]; then diff --git a/docs/20_Checks/check_dockercontainer_info.md b/docs/20_Checks/check_dockercontainer_info.md index 048283a60417a65014d9bf419655a15f0fa33009..c87063d8c9984ccfe3de2c42a0b401d79dc3b160 100644 --- a/docs/20_Checks/check_dockercontainer_info.md +++ b/docs/20_Checks/check_dockercontainer_info.md @@ -5,8 +5,6 @@ Script: `check_dockercontainer_info` List existing containers and show container details. To show details you can enter an id or define a regex -⚠️ This script is more experimental. - ## Requirements * `docker` Docker must be installed @@ -39,7 +37,7 @@ If DOCKER_HOST is not set then the docker socket is detected from a running dock ______________________________________________________________________ CHECK_DOCKERCONTAINER_INFO -v1.1 +v1.2 (c) Institute for Medical Education - University of Bern Licence: GNU GPL 3 @@ -90,8 +88,13 @@ None. ### Stats -`$ ./check_dockercontaeiner_top` returns +`$ ./check_dockercontaeiner_info -s` returns ```txt +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +31eff39f1582 php:8.4-apache "docker-php-entrypoi…" 10 days ago Exited (0) 24 hours ago mfa-server +9fa83e21142e appmonitor-appmonitor-web "docker-php-entrypoi…" 3 weeks ago Up 3 hours (healthy) 0.0.0.0:8001->80/tcp, :::8001->80/tcp appmonitor-server +7a03472377c4 phpmyadmin/phpmyadmin "/docker-entrypoint.…" 4 weeks ago Exited (0) 4 weeks ago phpmyadmin +835b49cc042c mariadb:10.5.28 "docker-entrypoint.s…" 4 weeks ago Exited (0) 4 weeks ago apost-db TODO ```