Created
September 21, 2017 18:39
-
-
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
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
#!/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