Skip to content

Instantly share code, notes, and snippets.

@kosfar
Created October 7, 2017 18:16
Show Gist options
  • Save kosfar/64e26929a0885c06fc10566d16a9919a to your computer and use it in GitHub Desktop.
Save kosfar/64e26929a0885c06fc10566d16a9919a to your computer and use it in GitHub Desktop.
#!/bin/bash
DEV="/dev/$1"
# `dmsetup info` is an option too, but needs root and still `find`
# is more interesting
DEVMAP=$(find -L /dev/mapper/ -samefile $DEV | sed -e "s/^\/dev\/mapper\///")
for containerid in $(docker ps -q); do
dockerdev=$(docker inspect --format='{{.GraphDriver.Data.DeviceName}}' $containerid)
if [ "$dockerdev" = "$DEVMAP" ]; then
taskdfn=$(docker inspect --format="{{ index .Config.Labels \"com.amazonaws.ecs.task-definition-family\"}}" $containerid)
echo -e "Containerid: $containerid\nTask definition:$taskdfn"
break
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment