#!/bin/bash

psid=$1

ids=$(docker inspect -f "{{.Id}}"  $(docker ps -q))

for did in $ids; do
    docker top $did | awk '{print $2, $3}' | grep -wq $psid
    if [[ $? -eq 0 ]]; then
        echo "Docker ID  : $did"
        name=$(docker inspect -f '{{.Name}}' $did | tr -d "/")
        echo "Docker Name: $name"
        exit 0
    fi
done

echo "Not a docker (sub)process..."

