WSLにインストールされているディストリビューションでルートPID名前空間をどのように入力しますか?

WSLにインストールされているディストリビューションでルートPID名前空間をどのように入力しますか?

私はWSL 2(Linux v2)用のWindowsサブシステムを使用しようとしましたが、よくある質問では、すべてのディストリビューションがHyper-Vの同じ仮想マシン(VM)にインストールされ、分離のためにスペースを使用して名前が付けられていることがわかりました。これは、UbuntuとDebianを起動し、次のコマンドを実行してアクティブな仮想マシンのリストを確認することで確認できます。

PS C:\Users\admin> hcsdiag list
8B389621-7C83-484C-8F24-5CAEDA29AA49
    VM,                         Running, 8B389621-7C83-484C-8F24-5CAEDA29AA49, WSL

これらのディストリビューションがネームスペースで区切られている場合、両方のディストリビューションで同じルートネームスペースを使用できないのはなぜですかnsenter

以下は、PID 1を使用するUbuntuディストリビューションで実行されるプロセスです/init

root@DESKTOP-5VNI36Q:~# ps -Af
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 14:05 ?        00:00:00 /init
root         7     1  0 14:05 ?        00:00:00 /init
root         8     7  0 14:05 ?        00:00:00 /init
nlykkei      9     8  0 14:05 pts/0    00:00:00 -bash
root        52     9  0 14:06 pts/0    00:00:00 sudo su -
root        53    52  0 14:06 pts/0    00:00:00 su -
root        54    53  0 14:06 pts/0    00:00:00 -bash
root        70    54  0 14:06 pts/0    00:00:00 ps -Af

UbuntuディストリビューションでPID 1のすべての名前空間を入力すると、元のものと同じPID名前空間が保持され、それ以上進むことはできません(下記参照)。

root@DESKTOP-5VNI36Q:~# nsenter-t1 -a

対照的に、DebianディストリビューションでPID 1のすべての名前空間を入力すると、進行できなくなり、元々作成したのと同じPID名前空間に閉じ込められます。また、PIDネームスペースはUbuntu PIDネームスペースとは異なります。

Ubuntu分配する:

root@DESKTOP-5VNI36Q:~# ls -la /proc/self/ns
total 0
dr-x--x--x 2 root root 0 Oct 20 14:06 .
dr-xr-xr-x 9 root root 0 Oct 20 14:06 ..
lrwxrwxrwx 1 root root 0 Oct 20 14:06 cgroup -> 'cgroup:[4026531835]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 ipc -> 'ipc:[4026532188]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 mnt -> 'mnt:[4026532186]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 net -> 'net:[4026531992]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 pid -> 'pid:[4026532189]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 pid_for_children -> 'pid:[4026532189]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 user -> 'user:[4026531837]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 uts -> 'uts:[4026532187]'
root@DESKTOP-5VNI36Q:~# ls -la /proc/1/ns
total 0
dr-x--x--x 2 root root 0 Oct 20 14:05 .
dr-xr-xr-x 9 root root 0 Oct 20 14:05 ..
lrwxrwxrwx 1 root root 0 Oct 20 14:06 cgroup -> 'cgroup:[4026531835]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 ipc -> 'ipc:[4026532188]'
lrwxrwxrwx 1 root root 0 Oct 20 14:05 mnt -> 'mnt:[4026532186]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 net -> 'net:[4026531992]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 pid -> 'pid:[4026532189]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 pid_for_children -> 'pid:[4026532189]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 user -> 'user:[4026531837]'
lrwxrwxrwx 1 root root 0 Oct 20 14:06 uts -> 'uts:[4026532187]'

ダーバン分配する:

root@DESKTOP-5VNI36Q:~# ls -la /proc/self/ns
total 0
dr-x--x--x 2 root root 0 Oct 20 14:10 .
dr-xr-xr-x 9 root root 0 Oct 20 14:10 ..
lrwxrwxrwx 1 root root 0 Oct 20 14:10 cgroup -> 'cgroup:[4026531835]'
lrwxrwxrwx 1 root root 0 Oct 20 14:10 ipc -> 'ipc:[4026532203]'
lrwxrwxrwx 1 root root 0 Oct 20 14:10 mnt -> 'mnt:[4026532211]'
lrwxrwxrwx 1 root root 0 Oct 20 14:10 net -> 'net:[4026531992]'
lrwxrwxrwx 1 root root 0 Oct 20 14:10 pid -> 'pid:[4026532204]'
lrwxrwxrwx 1 root root 0 Oct 20 14:10 pid_for_children -> 'pid:[4026532204]'
lrwxrwxrwx 1 root root 0 Oct 20 14:10 user -> 'user:[4026531837]'
lrwxrwxrwx 1 root root 0 Oct 20 14:10 uts -> 'uts:[4026532202]'
root@DESKTOP-5VNI36Q:~# ls -la /proc/1/ns
total 0
dr-x--x--x 2 root root 0 Oct 20 12:04 .
dr-xr-xr-x 9 root root 0 Oct 20 11:17 ..
lrwxrwxrwx 1 root root 0 Oct 20 12:04 cgroup -> 'cgroup:[4026531835]'
lrwxrwxrwx 1 root root 0 Oct 20 12:04 ipc -> 'ipc:[4026532203]'
lrwxrwxrwx 1 root root 0 Oct 20 12:04 mnt -> 'mnt:[4026532201]'
lrwxrwxrwx 1 root root 0 Oct 20 12:04 net -> 'net:[4026531992]'
lrwxrwxrwx 1 root root 0 Oct 20 12:04 pid -> 'pid:[4026532204]'
lrwxrwxrwx 1 root root 0 Oct 20 14:10 pid_for_children -> 'pid:[4026532204]'
lrwxrwxrwx 1 root root 0 Oct 20 12:04 user -> 'user:[4026531837]'
lrwxrwxrwx 1 root root 0 Oct 20 12:04 uts -> 'uts:[4026532202]'

ベストアンサー1

おすすめ記事