Skip to content

Instantly share code, notes, and snippets.

@cgmb
Created January 6, 2026 19:38
Show Gist options
  • Select an option

  • Save cgmb/79c1804590a7a7a5a926b6d699b930ff to your computer and use it in GitHub Desktop.

Select an option

Save cgmb/79c1804590a7a7a5a926b6d699b930ff to your computer and use it in GitHub Desktop.
Bash functions for identifying containers by files in root
function docker-files {
docker diff "$1" | cut -d/ -f2,3 | fgrep 'root/' | grep -v 'root/\.' | sed 's_root/__' | uniq
}
function docker-files-all {
local container_ids=$(docker ps -a | cut -d' ' -f1 | sed -n '1d;p')
for container_id in $container_ids; do
echo "$container_id:"
docker-files "$container_id" | sed 's/^/ /'
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment