Skip to content
Snippets Groups Projects
Commit e7e52009 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

usse sudo for dockerinfo check

parent c0ff856e
No related branches found
No related tags found
1 merge request!307usse sudo for dockerinfo check
This commit is part of merge request !307. Comments created here will be created in the context of that merge request.
......@@ -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
......
......@@ -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
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment