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