Created
July 26, 2021 13:15
-
-
Save georg-wolflein/2df4393070e29c877fff79230600eee7 to your computer and use it in GitHub Desktop.
Get the docker container ID containing a specified PID (useful to identify GPU-intensive processes when running nvidia-smi)
This file contains hidden or 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 | |
| if [ -z "$1" ] | |
| then | |
| echo "Supply a PID as an argument!" | |
| exit 1 | |
| fi | |
| for i in $(docker ps -q) | |
| do | |
| OUTPUT=$(docker container top "$i" | grep "$1") | |
| if [ $(docker container top "$i" | grep "$1" | wc -c) -ne 0 ] | |
| then | |
| docker ps -a | grep $i | |
| exit 0 | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment