Linux 使用 nsenter 进入 Docker 容器排查问题
Linux Docker 大约 684 字安装 nsenter
make&make build
方式,源码下载:
https://mirrors.edge.kernel.org/pub/linux/utils/util-linux
yum
安装
yum install util-linux -y
查看容器 PID
docker inspect --format "{{ .State.Pid}}" <container id>
进入容器命令
nsenter --target $PID --mount --uts --ipc --net --pid
参数说明
--mount
:进入到mount namespace
中
--uts
:进入到uts namespace
中
--ipc
:进入到System V IPC namaspace
中
--net
:进入到network namespace
中
--pid
:进入到pid namespace
中
--user
:进入到user namespace
中
-m 参数
加 m 参数
nsenter -t 容器PID -m -u -i -n -p
不加 m 参数
nsenter -t 容器PID -u -i -n -p
区别
加-m
:容器里没有ping
等命令
不加-m
:容器里有一些基础命令
原因
-m
是进入mount namespace
的,这个名称空间是用来文件系统名称空间,所以当我们不加-m
的时候,使用的是宿主机的文件系统,可以使用宿主机内的命令对容器进行问题的排查。
参考
阅读 557 · 发布于 2022-06-20
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Arthas 使用 tt 命令抓取调用异常、调用耗时、传入参数、返回参数阅读 3119
-
使用 kind 在 Docker 中部署 Kubernetes阅读 300
-
Spring 接口类型 getBeanNamesForType 获取实际类型的流程阅读 1296
-
Spring Boot 单元测试 @WebMvcTest 对 Controller 进行单独测试阅读 360
-
Linux CentOS6 安装 Docker阅读 4352
-
JMeter 登录后进行压测以及压测结束后退出阅读 1542
-
GoJS 加载 SVG 矢量图并分块填充颜色阅读 1896
-
尾部延迟是什么?如何避免尾部延迟?阅读 3498
-
Java 中的自旋锁阅读 1424
-
Docker 部署 Flink阅读 357