add new script to get docker registry-names
This commit is contained in:
parent
8057a013af
commit
5a6595f4b4
1 changed files with 20 additions and 0 deletions
20
get_registry-names.sh
Executable file
20
get_registry-names.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 1. Alle docker-compose.yml bis Tiefe 2 finden
|
||||
find . -maxdepth 2 -type f -name 'docker-compose.yml' | while read composefile; do
|
||||
# 2. Images extrahieren, Pfad mit ausgeben
|
||||
grep -E '^\s*image:' "$composefile" | awk -v file="$composefile" '{print file ": " $2}'
|
||||
done | \
|
||||
# 3. Registry extrahieren und gruppieren
|
||||
awk -F'image:' '{gsub(/^[ \t]+|[ \t]+$/, "", $2); print $1 $2}' | \
|
||||
awk -F': ' '{
|
||||
image = $2
|
||||
# Registry extrahieren
|
||||
split(image, parts, "/")
|
||||
if (length(parts) > 1 && index(parts[1], ".") > 0) {
|
||||
registry = parts[1]
|
||||
} else {
|
||||
registry = "docker.io"
|
||||
}
|
||||
print registry ": " image " (" $1 ")"
|
||||
}' | sort | uniq
|
Loading…
Add table
Reference in a new issue