Skip to content

Instantly share code, notes, and snippets.

@jbrisbin
Created September 21, 2017 18:39
Show Gist options
  • Save jbrisbin/525f269688c284f9ba9e689b92b4b3ef to your computer and use it in GitHub Desktop.
Save jbrisbin/525f269688c284f9ba9e689b92b4b3ef to your computer and use it in GitHub Desktop.
BASH script to get a procfile from a Docker container for a given process
#!/bin/bash
PROCESS=$1
PROC_FILE=${2:-status}
CONTAINERS=$(docker ps -q)
for c in $CONTAINERS; do
PIDS=$(docker exec $c ps ax | egrep $PROCESS | egrep -v grep | awk '{print $1}')
if [[ ! -z "$PIDS" ]]; then
echo "==== $c"
for PID in $PIDS; do
echo "===="
docker exec --user root $c cat /proc/$PID/$PROC_FILE
done
echo "===="
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment