Docker - 根据端口定位容器

2021-08-26
#!/bin/bash
result_dir="/tmp/result"
rm -rf /tmp/result
mkdir -p ${result_dir}
#containerids=$(docker ps | grep -v "/pause" | awk '{print $1}')
containerids=$(docker ps | awk '{print $1}')
for containerid in ${containerids}
do
    pid=$(docker inspect -f '{{.State.Pid}}' ${containerid})
    nsenter -t ${pid} -n netstat >  ${result_dir}/${containerid}-${pid}
done
echo "结果输出至:" ${result_dir}

标题:Docker - 根据端口定位容器
地址:https://blog.nijianqiang.xyz:8443/articles/2021/07/31/1627669921911.html