TenForward

技術ブログ。はてなダイアリーから移転しました

util-linux の nsenter コマンド

util-linuxの 2.23 (現在 2.23-rc1) で nsenter なるコマンドが追加されてるみたいですね.

lxc-attach と同様の事ができそうです,と思って試してみました.

  1. lxc-start でコンテナ起動
    # lxc-start -n test01 -d
  2. lxc-info で init の PID を調査
    # lxc-info -n test01
    state: RUNNING
    pid: 22505
  3. nsenter コマンド実行
    • uname -a
      # nsenter -t 22505 -m -u -i -n -p -- /bin/uname -a 
      Linux test01 3.8.5-plamo64 #2 SMP PREEMPT Fri Mar 29 18:57:42 JST 2013 x86_64 GNU/Linux
    • bash
      # nsenter -t 22505 -m -u -i -n -p /bin/bash
      root@test01:/# ifconfig
      eth0 Link encap:Ethernet HWaddr 32:93:a1:96:93:c2
      inet addr:10.0.100.179 Bcast:10.0.100.255 Mask:255.255.255.0
      ...(snip)

あまり中身のないコネタでした ^^;

lxc-attach コマンドの方は実行した後の環境変数とかパスとかどうする? みたいな話になってますね.