lxc-attach.sgml.in revision 6127da6b3f5815028bee187ac98840cd94313841
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumilxc: linux Container library
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi(C) Copyright IBM Corp. 2007, 2008
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiDaniel Lezcano <daniel.lezcano at free.fr>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiThis library is free software; you can redistribute it and/or
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumimodify it under the terms of the GNU Lesser General Public
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLicense as published by the Free Software Foundation; either
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiversion 2.1 of the License, or (at your option) any later version.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiThis library is distributed in the hope that it will be useful,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumibut WITHOUT ANY WARRANTY; without even the implied warranty of
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLesser General Public License for more details.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiYou should have received a copy of the GNU Lesser General Public
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLicense along with this library; if not, write to the Free Software
a5ba96715d4ef264c43d4f187251de491ba198c0KATOH YasufumiFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
8900b9eb2514c07047541833286428572493a9fdStéphane GraberTranslated into Japanese
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumiby KATOH Yasufumi <karma at jazz.email.ne.jp>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi<!ENTITY commonoptions SYSTEM "@builddir@/common_options.sgml">
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi start a process inside a running container.
6127da6b3f5815028bee187ac98840cd94313841KATOH Yasufumi 実行中のコンテナ内でプロセスの開始
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </refpurpose>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </refnamediv>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <refsynopsisdiv>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <cmdsynopsis>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <arg choice="req">-n <replaceable>name</replaceable></arg>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <arg choice="opt">-a <replaceable>arch</replaceable></arg>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <arg choice="opt">-s <replaceable>namespaces</replaceable></arg>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <arg choice="opt">-- <replaceable>command</replaceable></arg>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </cmdsynopsis>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </refsynopsisdiv>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <command>lxc-attach</command> runs the specified
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>command</replaceable> inside the container
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi specified by <replaceable>name</replaceable>. The container
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi has to be running already.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <command>lxc-attach</command> は <replaceable>name</replaceable> で指定したコンテナ内で指定した <replaceable>command</replaceable> を実行します.実行する時点でコンテナが実行中でなければなりません.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi If no <replaceable>command</replaceable> is specified, the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi current default shell of the user running
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <command>lxc-attach</command> will be looked up inside the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi container and executed. This will fail if no such user exists
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi inside the container or the container does not have a working
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi nsswitch mechanism.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi もし <replaceable>command</replaceable> が指定されていない場合,<command>lxc-attach</command> コマンドを実行したユーザのデフォルトシェルをコンテナ内で調べて実行します.もしコンテナ内にユーザが存在しない場合や,コンテナで nsswitch 機構が働いていない場合はこの動作は失敗します.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <variablelist>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <option>-a, --arch <replaceable>arch</replaceable></option>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Specify the architecture which the kernel should appear to be
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi running as to the command executed. This option will accept the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi same settings as the <option>lxc.arch</option> option in
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi container configuration files, see
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <citerefentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <refentrytitle><filename>lxc.conf</filename></refentrytitle>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <manvolnum>5</manvolnum>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </citerefentry>. By default, the current archictecture of the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi running container will be used.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi コマンドを実行するコンテナのアーキテクチャを指定します.このオプションは,コンテナの設定ファイルで指定する <option>lxc.arch</option> オプションと同じものとして受け入れられます.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <citerefentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <refentrytitle><filename>lxc.conf</filename></refentrytitle>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </citerefentry> を参照してください.デフォルトでは,実行しているコンテナのアーキテクチャになります.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Do not drop privileges when running
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>command</replaceable> inside the container. If
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi this option is specified, the new process will
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <emphasis>not</emphasis> be added to the container's cgroup(s)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi and it will not drop its capabilities before executing.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi コンテナの内部で <replaceable>command</replaceable> を実行する時に特権を削除しません.もしこのオプションが指定された場合,新しいプロセスはコンテナの cgroup に追加 <emphasis>されず</emphasis>,実行する前にケーパビリティ (capability) も削除しません.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <emphasis>Warning:</emphasis> This may leak privileges into the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi container if the command starts subprocesses that remain active
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi after the main process that was attached is terminated. The
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi (re-)starting of daemons inside the container is problematic,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi especially if the daemon starts a lot of subprocesses such as
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <command>cron</command> or <command>sshd</command>.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <emphasis>Use with great care.</emphasis>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <emphasis>警告:</emphasis>もし実行するコマンドが,アタッチするメインプロセスが終了した後も実行されたままのサブプロセスを開始するような場合,このオプションの指定はコンテナ内への特権のリークとなる可能性があります.コンテナ内でのデーモンの開始(もしくは再起動)は問題となります.デーモンが多数のサブプロセスを開始する <command>cron</command> や <command>sshd</command> のような場合は特に問題となります.<emphasis>充分な注意を払って使用してください.</emphasis>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <option>-s, --namespaces <replaceable>namespaces</replaceable></option>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Specify the namespaces to attach to, as a pipe-separated list,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi e.g. <replaceable>NETWORK|IPC</replaceable>. Allowed values are
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>MOUNT</replaceable>, <replaceable>PID</replaceable>,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>UTSNAME</replaceable>, <replaceable>IPC</replaceable>,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>USER </replaceable> and
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>NETWORK</replaceable>. This allows one to change
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi the context of the process to e.g. the network namespace of the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi container while retaining the other namespaces as those of the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi アタッチする名前空間をパイプで連結したリストで指定します.例えば <replaceable>NETWORK|IPC</replaceable> のようにです.ここで使用可能な値は <replaceable>MOUNT</replaceable>, <replaceable>PID</replaceable>, <replaceable>UTSNAME</replaceable>, <replaceable>IPC</replaceable>, <replaceable>USER </replaceable>, <replaceable>NETWORK</replaceable> です.これにより指定した名前空間にプロセスのコンテキストを変更できます.例えばコンテナのネットワーク名前空間に変更する一方で,他の名前空間はホストの名前空間のままにするというような事が可能です.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <emphasis>Important:</emphasis> This option implies
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <option>-e</option>.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <emphasis>重要:</emphasis> このオプションは <option>-e</option> オプションを指定しなくても指定している場合と同様の動作をします.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi When using <option>-s</option> and the mount namespace is not
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi included, this flag will cause <command>lxc-attach</command>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi to remount <replaceable>/proc</replaceable> and
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>/sys</replaceable> to reflect the current other
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi namespace contexts.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <option>-s</option> を指定し,そこにマウント名前空間が含まれない時,このオプションにより <command>lxc-attach</command> は <replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> をリマウントします.これは現在の他の名前空間のコンテキストを反映させるためです.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Please see the <emphasis>Notes</emphasis> section for more
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi This option will be ignored if one tries to attach to the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi mount namespace anyway.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi このオプションは,マウント名前空間へのアタッチが行われる場合は無視されます.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Keep the current environment for attached programs. This is
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi the current default behaviour (as of version 0.9), but is
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi is likely to change in the future, since this may leak
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi undesirable information into the container. If you rely on
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi the environment being available for the attached program,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi please use this option to be future-proof. In addition to
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi current environment variables, container=lxc will be set.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi アタッチされるプログラムに対して現在の環境を保持したままにします.これは現在 (バージョン 0.9 時点) のデフォルトの動作ですが,将来は変更される予定です.この動作がコンテナ内への望ましくない情報の漏洩につながる可能性があるためです.アタッチするプログラムで環境変数が利用可能であることを期待している場合,将来的にもそれが保証されるようにこのオプションを使用するようにしてください.現在の環境変数に加えて,container=lxc が設定されます.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Clear the environment before attaching, so no undesired
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi environment variables leak into the container. The variable
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi container=lxc will be the only environment with which the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi attached program starts.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi アタッチする前に環境変数をクリアします.これによりコンテナへの不要な環境変数の漏洩が起こらなくなります.変数 container=lxc のみがアタッチするプログラムの開始の時の環境変数となります.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </variablelist>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi &commonoptions;
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi To spawn a new shell running inside an existing container, use
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi lxc-attach -n container
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi 存在するコンテナ内で新しいシェルを生成するには,以下のようにします.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi lxc-attach -n container
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi To restart the cron service of a running Debian container, use
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi lxc-attach -n container -- /etc/init.d/cron restart
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi 実行中の Debian コンテナの cron サービスを再起動するには,以下のように実行します.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi lxc-attach -n container -- /etc/init.d/cron restart
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi To deactivate the network link eth1 of a running container that
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi does not have the NET_ADMIN capability, use either the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <option>-e</option> option to use increased capabilities,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi assuming the <command>ip</command> tool is installed:
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi lxc-attach -n container -e -- /sbin/ip link delete eth1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi NET_ADMIN ケーパビリティを持たない実行中のコンテナのネットワークインターフェース eth1 の動作を停止させるには,ケーパビリティを増加させるために <option>-e</option> オプションを指定し,<command>ip</command> ツールがインストールされていることを前提に,以下のように実行します.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi lxc-attach -n container -e -- /sbin/ip link delete eth1
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </programlisting>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Attaching completely (including the pid and mount namespaces) to a
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi container requires a patched kernel, please see the lxc website for
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi details. <command>lxc-attach</command> will fail in that case if
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi used with an unpatched kernel.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi (pid とマウント名前空間を含む) コンテナに対する完全なアタッチを行うにはパッチを適用したカーネルが必要となります.詳しくは lxc のウェブサイトを参照してください.(訳注: 3.8 カーネルから PID, マウント名前空間に対するアタッチも可能になっている)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Nevertheless, it will succeed on an unpatched kernel of version 3.0
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi or higher if the <option>-s</option> option is used to restrict the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi namespaces that the process is to be attached to to one or more of
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>NETWORK</replaceable>, <replaceable>IPC</replaceable>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi and <replaceable>UTSNAME</replaceable>.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi しかし,もし <option>-s</option> を使用して,アタッチするものを <replaceable>NETWORK</replaceable>, <replaceable>IPC</replaceable>, <replaceable>UTSNAME</replaceable> の 1 つか複数の名前空間に限定して使用すれば,バージョン 3.0 以上のパッチを適用していないカーネルでもアタッチが成功するでしょう.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Attaching to user namespaces is currently completely unsupported
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi by the kernel. <command>lxc-attach</command> should however be able
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi to do this once once future kernel versions implement this.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi ユーザ名前空間へのアタッチは,現時点ではカーネルで完全にサポートされていません.しかし,<command>lxc-attach</command> は,将来のカーネルがこの機能を実装した時点ですぐに,アタッチが可能になるはずです.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi The Linux <replaceable>/proc</replaceable> and
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>/sys</replaceable> filesystems contain information
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi about some quantities that are affected by namespaces, such as
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi the directories named after process ids in
36b33520f67cd1a83be8031fccc3c2d7d7255e06Stéphane Graber <replaceable>/proc</replaceable> or the network interface information
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi in <replaceable>/sys/class/net</replaceable>. The namespace of the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi process mounting the pseudo-filesystems determines what information
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi is shown, <emphasis>not</emphasis> the namespace of the process
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi accessing <replaceable>/proc</replaceable> or
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>/sys</replaceable>.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi Linux の <replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> ファイルシステムは名前空間によって影響を受けるいくつかの情報を持っています.これは <replaceable>/proc</replaceable> 内のプロセス ID の名前のディレクトリや,<replaceable>/sys/class/net</replaceable> 内のネットワークインターフェース名のディレクトリなどです.擬似ファイルシステムをマウントしているプロセスの名前空間が,どのような情報を表示するかを決定します.<replaceable>/proc</replaceable> や <replaceable>/sys</replaceable> にアクセスしているプロセスの名前空間が決定するのではありません.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi If one uses the <option>-s</option> option to only attach to
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi the pid namespace of a container, but not its mount namespace
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi (which will contain the <replaceable>/proc</replaceable> of the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi container and not the host), the contents of <option>/proc</option>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi will reflect that of the host and not the container. Analogously,
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi the same issue occurs when reading the contents of
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>/sys/class/net</replaceable> and attaching to just
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi the network namespace.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <option>-s</option> を使ってコンテナの pid 名前空間のみをアタッチし,マウント名前空間 (これはコンテナの <replaceable>/proc</replaceable> を含み,ホストのは含まないでしょう) はアタッチしない場合,<option>/proc</option> のコンテンツはコンテナのものではなく,ホストのものとなります.似たような事例として,ネットワーク名前空間のみをアタッチして,<replaceable>/sys/class/net</replaceable> のコンテンツを読んだ場合も同じような事が起こるでしょう.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi To work around this problem, the <option>-R</option> flag provides
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi the option to remount <replaceable>/proc</replaceable> and
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>/sys</replaceable> in order for them to reflect the
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi network/pid namespace context of the attached process. In order
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi not to interfere with the host's actual filesystem, the mount
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi namespace will be unshared (like <command>lxc-unshare</command>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi does) before this is done, esentially giving the process a new
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi mount namespace, which is identical to the hosts's mount namespace
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi except for the <replaceable>/proc</replaceable> and
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <replaceable>/sys</replaceable> filesystems.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi この問題への対処のために,<option>-R</option> オプションが <replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> が提供されています.これにより,アタッチするプロセスのネットワーク/pid 名前空間のコンテキストを反映させることができます.ホストの実際のファイルシステムに影響を与えないために,実行前にはマウント名前空間は unshare されます (<command>lxc-unshare</command> のように).これは,<replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> ファイルシステム以外はホストのマウント名前空間と同じである,新しいマウント名前空間がプロセスに与えられるということです.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi The <option>-e</option> and <option>-s</option> options should
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi be used with care, as it may break the isolation of the containers
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi if used improperly.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <option>-e</option> と <option>-s</option> オプションの使用には注意を払うべきです.不適切に使用した場合,コンテナの隔離を破壊してしまう可能性があります.
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <para>Daniel Lezcano <email>daniel.lezcano@free.fr</email></para>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi<!-- Keep this comment at the end of the file
57da8c32f85c0255efa61ee32e260068afdaa565KATOH YasufumiLocal variables:
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-omittag:t
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-shorttag:t
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-minimize-attributes:nil
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-always-quote-attributes:t
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-indent-step:2
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-indent-data:t
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-parent-document:nil
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-default-dtd-file:nil
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-exposed-tags:nil
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-local-catalogs:nil
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumisgml-local-ecat-files:nil