Created
February 15, 2023 02:36
-
-
Save Owen-Liuyuxuan/726cb8d13a6019bd42f27b7432d012eb to your computer and use it in GitHub Desktop.
Find container with certain PID.
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 -e | |
# Prints the name of the container inside which the process with a PID on the host is. | |
# Usage./FindContainerwithPID <pid> | |
for container in $(docker ps -q); do | |
status=`docker top $container | grep $1 | wc -l` | |
if [ $status == "0" ]; then | |
echo "NOT" | |
else | |
docker ps | grep $container | |
fi | |
done; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment