2022-08-18 10:32:14 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
for CONTAINER_ID in $(docker ps -aq) # get list of all loaded containers (running and stopped)
|
|
|
|
do
|
|
|
|
CONTAINER_NAME=$(docker ps -aq --filter "id=$CONTAINER_ID" --format '{{.Names}}') # get the container's name
|
|
|
|
CONTAINER_MOUNTS=$(docker inspect --format '{{range .Mounts}}{{println .Source}}{{end}}' $CONTAINER_ID) # print the container's volume mounts
|
2022-08-18 10:34:33 -07:00
|
|
|
echo "======== CHECKING $CONTAINER_NAME ========"
|
2022-08-18 10:48:10 -07:00
|
|
|
echo "$CONTAINER_MOUNTS" | grep /mnt/nas
|
2022-08-18 10:52:31 -07:00
|
|
|
MATCH=$?
|
2022-08-18 10:55:36 -07:00
|
|
|
echo "$MATCH"
|
2022-08-18 10:54:50 -07:00
|
|
|
if $MATCH; then
|
2022-08-18 10:53:37 -07:00
|
|
|
echo "NAS DEPENDENT"
|
|
|
|
else
|
|
|
|
echo "NOT NAS DEPENDENT"
|
|
|
|
fi
|
2022-08-18 10:32:14 -07:00
|
|
|
done
|