-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdocker_logs_down.sh
executable file
·30 lines (24 loc) · 1.12 KB
/
docker_logs_down.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
die() { echo "$@" 1>&2 ; exit 1; }
[ "$#" -eq 1 ] || die "[docker-tools] 1 argument required ('STACK name'), $# provided"
STACK="$1"
for status in "created" "restarting" "removing" "paused" "exited" "dead"
do
for sid in $(docker container ls --filter "status=$status" -q); do
stack=$(docker inspect --format "{{index .Config.Labels \"com.docker.stack.namespace\" }}" $sid)
if [[ "$stack" == "$STACK" ]];then
echo " "
echo "[docker-tools] --------------------------------------------------------------------------------------------"
echo "[docker-tools] ID " $(docker inspect --format "{{.ID}}" $sid)
echo "[docker-tools] Name " $(docker inspect --format "{{.Name}}" $sid)
echo "[docker-tools] Status " $(docker inspect --format "{{.State.Status}}" $sid)
echo "[docker-tools] FinishedAt" $(docker inspect --format "{{.State.FinishedAt}}" $sid) | sed -r 's/T/\t/g'
echo " "
docker logs $sid
echo " "
echo " "
echo " "
echo " "
fi
done
done