PID –> Container ID
crictl ps | grep $(nsenter -u -t PID hostname)|cut -d' ' -f1
nsenter -u -t PID hostname
PID –> Pod ID
crictl ps | grep $(nsenter -u -t PID hostname) | awk '{print $(NF-1)}'
Container ID –> Pod ID
crictl ps | grep CONTAINER_ID | awk '{print $(NF-1)}'
Container ID –> PIDs
pstree -p $(crictl inspect -o json CONTAINER_ID|jq '.info.pid')
pstree -p $(docker inspect --format '{{.State.Pid}}' CONTAINER_ID)
# or
docker top CONTAINER_ID
Pod ID –> Container ID
crictl ps | grep POD_ID | awk '{print $1}'
Pod ID –> PIDs
for CID in $(crictl ps|grep POD_ID|awk '{print $1}'); do ROOT_PID=$(crictl inspect -o json $CID|jq '.info.pid'); pstree -p $ROOT_PID; done
相关