nsenter使用和debug使用

1、nsenter

由于有时候,容器中工具缺少难以定位,可以尝试使用nsenter

step1: 找到容器的pid

          docker inspect container_id | grep Pid

step2:  nsenter -t pid -m -n -p -i -u 

     -m ,如果带上,表示使用pid 的mnt,即:/proc/pid/ns/mnt

          如果不带上,就是当前的ns mnt

     -n netnamespaces

     -p pidnamespaces

     -i ipcnamespaces

     -u uts namespaces

注意:有时候全加会有问题,所以少加点,比如测网络,就加-n

2、debug container

如果有镜像含有工具,你想利用该工具进行定位,可以采用:公用pid和network

docker run -it --net container:nginx --pid container:nginx netshoot:latest bash

 

 

 

 

 

 

     

posted on 2021-01-23 20:26  星星眨着眼  阅读(217)  评论(0编辑  收藏  举报

导航