常见ns
mnt
uts
ipc
pid
lsns:查看容器的ns
[root@182 ~]# lsns
NS TYPE NPROCS PID USER COMMAND
4026531836 pid 256 1 root /usr/lib/systemd/systemd --switched-root --system --deserialize 22
4026531856 mnt 1 88 root kdevtmpfs
4026531962 net 256 1 root /usr/lib/systemd/systemd --switched-root --system --deserialize 22
4026532276 mnt 1 886 root /usr/sbin/NetworkManager --no-daemon
4026532277 mnt 1 921 chrony /usr/sbin/chronyd
4026532281 mnt 1 53383 polkitd mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --coll
4026532286 net 1 53383 polkitd mysqld --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --coll
4026532601 mnt 1 55144 polkitd redis-server *:6379
4026532602 uts 1 55144 polkitd redis-server *:6379
4026532603 ipc 1 55144 polkitd redis-server *:6379
nsenter :容器进入namespace
安装
wget https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.37/util-linux-2.37.2.tar.gz --no-check-certificate
tar -xf util-linux-2.37.2.tar.gz
cd util-linux-2.37.2/
./configure --without-ncurses
make nsenter
进入容器ns
PID=$(docker inspect --format {{.State.Pid}} <container_name_or_ID>)
nsenter --target $PID --mount --uts --ipc --net --pid