Created
February 2, 2017 19:21
-
-
Save euank/c49be5652decf9b165c719a16c7da540 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pid=${1:?must provide pid argument} | |
function getMntns() { | |
ls -ali /proc/$1/ns/mnt | sed 's/.*mnt:\[\([0-9]\+\)\].*/\1/' | |
} | |
targetns=$(getMntns $pid) | |
for container in $(docker inspect --format '{{.State.Pid }}-{{ .Id }}' $(docker ps -q)); do | |
cpid=$(echo $container | awk -F- '{print $1}') | |
mntns=$(getMntns $cpid) | |
if [[ "${mntns}" == "${targetns}" ]]; then | |
echo "Found container id: $(echo $container | awk -F- '{print $2}')" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment