Skip to content

Instantly share code, notes, and snippets.

@zhao-jin
zhao-jin / docker_desc.sh
Created July 2, 2022 06:50 — forked from mlinhard/docker_desc.sh
Shell script to find docker image descendants
#!/bin/bash
parent_short_id=$1
parent_id=`docker inspect --format '{{.Id}}' $1`
get_kids() {
local parent_id=$1
docker inspect --format='ID {{.Id}} PAR {{.Parent}}' $(docker images -a -q) | grep "PAR ${parent_id}" | sed -E "s/ID ([^ ]*) PAR ([^ ]*)/\1/g"
}
print_kids() {