Skip to content

Instantly share code, notes, and snippets.

@polvi
Created January 13, 2014 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save polvi/5f89db1c8609b06437e8 to your computer and use it in GitHub Desktop.
Save polvi/5f89db1c8609b06437e8 to your computer and use it in GitHub Desktop.
#!/bin/bash
CONT=$1
C=$(docker ps | grep $CONT | awk '{print $1}')
# "block" until the container shows up, yikes
while [ -z "$C" ]; do
C=$(docker ps | grep $CONT | awk '{print $1}')
sleep .5
done
NS_PID=$(ps aux | grep $C | grep -v grep | awk '{print $2}' | xargs ps -o pid --no-headers --ppid | head -n 1)
echo $NS_PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment