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>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <arg choice="req">-n, --name <replaceable>name</replaceable></arg>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <arg choice="opt">-f, --rcfile <replaceable>config_file</replaceable></arg>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <arg choice="opt">-a, --arch <replaceable>arch</replaceable></arg>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <arg choice="opt">-e, --elevated-privileges <replaceable>privileges</replaceable></arg>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <arg choice="opt">-s, --namespaces <replaceable>namespaces</replaceable></arg>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <arg choice="opt">-R, --remount-sys-proc</arg>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <arg choice="opt">-L, --pty-log <replaceable>file</replaceable></arg>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <arg choice="opt">-v, --set-var <replaceable>variable</replaceable></arg>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <arg choice="opt">--keep-var <replaceable>variable</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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi <command>lxc-attach</command> は <replaceable>name</replaceable> で指定したコンテナ内で指定した <replaceable>command</replaceable> を実行します。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 実行する時点でコンテナが実行中でなければなりません。
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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi もし <replaceable>command</replaceable> が指定されていない場合、<command>lxc-attach</command> コマンドを実行したユーザのデフォルトシェルをコンテナ内で調べて実行します。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi もしコンテナ内にユーザが存在しない場合や、コンテナで nsswitch 機構が働いていない場合はこの動作は失敗します。
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi Previous versions of <command>lxc-attach</command> simply attached to the
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi specified namespaces of a container and ran a shell or the specified command
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi without first allocating a pseudo terminal. This made them vulnerable to
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi input faking via a TIOCSTI <command>ioctl</command> call after switching
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi between userspace execution contexts with different privilege levels. Newer
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi versions of <command>lxc-attach</command> will try to allocate a pseudo
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi terminal master/slave pair on the host and attach any standard file
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi descriptors which refer to a terminal to the slave side of the pseudo
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi terminal before executing a shell or command. Note, that if none of the
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi standard file descriptors refer to a terminal <command>lxc-attach</command>
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi will not try to allocate a pseudo terminal. Instead it will simply attach
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi to the containers namespaces and run a shell or the specified command.
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi 前のバージョンの <command>lxc-attach</command> は、単に指定したコンテナの名前空間にアタッチし、最初に擬似端末 (pseudo terminal) を割り当てないで、シェルもしくは指定したコマンドを実行しました。
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi これは、異なる特権レベルを持つユーザ空間の実行コンテキストを切り替えた後に、TIOCSTI <command>ioctl</command> の呼び出し経由で擬似入力を行うことに対して脆弱となります。
f025e64819ea14ea5f87eae652a1666cdcbb640eKATOH Yasufumi 新しいバージョンの <command>lxc-attach</command> は、ホスト上の擬似端末のマスター/スレーブのペアを割り当てようとします。そしてシェルやコマンドを実行する前に、擬似端末のスレーブ側に対して、ターミナルを参照する標準ファイルディスクリプタをアタッチします。
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi ターミナルを参照する標準ファイルディスクリプタがない場合は、<command>lxc-attach</command> は擬似端末の割り当てを行わないことに注意してください。代わりに、単にコンテナの名前空間にアタッチし、シェルや指定したコマンドを実行します。
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <variablelist>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <varlistentry>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <option>-f, --rcfile <replaceable>config_file</replaceable></option>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi Specify the configuration file to configure the virtualization
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi and isolation functionalities for the container.
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi コンテナの仮想化、隔離機能の設定のための設定ファイルを指定します。
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi This configuration file if present will be used even if there is
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi already a configuration file present in the previously created
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi container (via lxc-create).
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi (lxc-create 経由で) 前もってコンテナが作られた際の設定ファイルが既にあった場合でも、このオプションが指定された場合は、指定した設定ファイルが使用されます。
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi </varlistentry>
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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi コマンドを実行するコンテナのアーキテクチャを指定します。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi このオプションは、コンテナの設定ファイルで指定する <option>lxc.arch</option> オプションと同じものが使用可能です。
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <citerefentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <refentrytitle><filename>lxc.conf</filename></refentrytitle>
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi </citerefentry> を参照してください。デフォルトでは、実行しているコンテナのアーキテクチャになります。
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </varlistentry>
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <varlistentry>
1b29d73cba7a54227f937969de05fc0cfa07580aKATOH Yasufumi -e, --elevated-privileges <replaceable>privileges</replaceable>
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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi コンテナの内部で <replaceable>command</replaceable> を実行する時に特権を削除しません。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi もしこのオプションが指定された場合、新しいプロセスはコンテナの cgroup に追加 <emphasis>されず</emphasis>、実行する前にケーパビリティ (capability) も削除しません。
1b29d73cba7a54227f937969de05fc0cfa07580aKATOH Yasufumi You may specify privileges, in case you do not want to elevate all of
1b29d73cba7a54227f937969de05fc0cfa07580aKATOH Yasufumi them, as a pipe-separated list, e.g.
1b29d73cba7a54227f937969de05fc0cfa07580aKATOH Yasufumi <replaceable>CGROUP|LSM</replaceable>. Allowed values are
1b29d73cba7a54227f937969de05fc0cfa07580aKATOH Yasufumi <replaceable>CGROUP</replaceable>, <replaceable>CAP</replaceable> and
1b29d73cba7a54227f937969de05fc0cfa07580aKATOH Yasufumi <replaceable>LSM</replaceable> representing cgroup, capabilities and
352470062e49751bca512a2817446962a35aedc0KATOH Yasufumi restriction privileges respectively. (The pipe symbol needs to be escaped,
352470062e49751bca512a2817446962a35aedc0KATOH Yasufumi e.g. <replaceable>CGROUP\|LSM</replaceable> or quoted, e.g.
352470062e49751bca512a2817446962a35aedc0KATOH Yasufumi <replaceable>"CGROUP|LSM"</replaceable>.)
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 全ての特権の取得したくない場合は、パイプで連結したリストとして、例えば <replaceable>CGROUP|LSM</replaceable> のように、特権を指定することが可能です。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 指定できる値は、それぞれ cgroup、ケーパビリティ、特権の制限を表す <replaceable>CGROUP</replaceable>、<replaceable>CAP</replaceable>、<replaceable>LSM</replaceable> です。
352470062e49751bca512a2817446962a35aedc0KATOH Yasufumi (パイプ記号を <replaceable>CGROUP\|LSM</replaceable> のようにエスケープするか、<replaceable>"CGROUP|LSM"</replaceable> のように引用符号を付ける必要があります。)
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>
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi もし実行するコマンドが、アタッチするメインプロセスが終了した後も実行されたままのサブプロセスを開始するような場合、このオプションの指定はコンテナ内への特権のリークとなる可能性があります。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi コンテナ内でのデーモンの開始(もしくは再起動)は問題となります。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi デーモンが多数のサブプロセスを開始する <command>cron</command> や <command>sshd</command> のような場合は特に問題となります。
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
352470062e49751bca512a2817446962a35aedc0KATOH Yasufumi host. (The pipe symbol needs to be escaped, e.g.
352470062e49751bca512a2817446962a35aedc0KATOH Yasufumi <replaceable>MOUNT\|PID</replaceable> or quoted, e.g.
352470062e49751bca512a2817446962a35aedc0KATOH Yasufumi <replaceable>"MOUNT|PID"</replaceable>.)
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi アタッチする名前空間をパイプで連結したリストで指定します。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 例えば <replaceable>NETWORK|IPC</replaceable> のようにです。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi ここで使用可能な値は <replaceable>MOUNT</replaceable>, <replaceable>PID</replaceable>, <replaceable>UTSNAME</replaceable>, <replaceable>IPC</replaceable>, <replaceable>USER </replaceable>, <replaceable>NETWORK</replaceable> です。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi これにより指定した名前空間にプロセスのコンテキストを変更できます。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 例えばコンテナのネットワーク名前空間に変更する一方で、他の名前空間はホストの名前空間のままにするというような事が可能です。
352470062e49751bca512a2817446962a35aedc0KATOH Yasufumi (パイプ記号を <replaceable>MOUNT\|PID</replaceable> のようにエスケープするか、<replaceable>"MOUNT|PID"</replaceable> のように引用符号を付ける必要があります。)
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <emphasis>Important:</emphasis> This option implies
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi <option>-e</option>.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH 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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi <option>-s</option> を指定し、そこにマウント名前空間が含まれない時、このオプションにより <command>lxc-attach</command> は <replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> をリマウントします。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi これは現在の他の名前空間のコンテキストを反映させるためです。
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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH 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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi アタッチされるプログラムに対して現在の環境を保持したままにします。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi これは現在 (バージョン 0.9 時点) のデフォルトの動作ですが、将来は変更される予定です。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi この動作がコンテナ内への望ましくない情報の漏洩につながる可能性があるためです。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi アタッチするプログラムで環境変数が利用可能であることを期待している場合、将来的にもそれが保証されるようにこのオプションを使用するようにしてください。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 現在の環境変数に加えて、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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi アタッチする前に環境変数をクリアします。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi これによりコンテナへの不要な環境変数の漏洩が起こらなくなります。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 変数 container=lxc のみがアタッチするプログラムの開始の時の環境変数となります。
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi </varlistentry>
b1b14a4e3e215e228d09d99911603b25b98049b7KATOH Yasufumi <varlistentry>
b1b14a4e3e215e228d09d99911603b25b98049b7KATOH Yasufumi <option>-L, --pty-log <replaceable>file</replaceable></option>
b1b14a4e3e215e228d09d99911603b25b98049b7KATOH Yasufumi Specify a file where the output of <command>lxc-attach</command> will be
b1b14a4e3e215e228d09d99911603b25b98049b7KATOH Yasufumi <command>lxc-attach</command> の出力を記録するファイルを指定します。
b1b14a4e3e215e228d09d99911603b25b98049b7KATOH Yasufumi <emphasis>Important:</emphasis> When a standard file descriptor
659ce93a2e405f928cd4e1a457270572571a8db8Stéphane Graber does not refer to a pty output produced on it will not be logged.
b1b14a4e3e215e228d09d99911603b25b98049b7KATOH Yasufumi <emphasis>重要:</emphasis> 標準ファイルディスクリプタが pty を参照していない場合、それらに対する出力は記録されないでしょう。
b1b14a4e3e215e228d09d99911603b25b98049b7KATOH Yasufumi </varlistentry>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <varlistentry>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <option>-v, --set-var <replaceable>variable</replaceable></option>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi Set an additional environment variable that is seen by the
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi attached program in the container. It is specified in the
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi form of "VAR=VALUE", and can be specified multiple times.
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi コンテナにアタッチしたプログラムから見える環境変数を追加します。このオプションは "VAR=VALUE" の形式で指定し、複数回指定できます。
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi </varlistentry>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <varlistentry>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <option>--keep-var <replaceable>variable</replaceable></option>
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi Keep a specified environment variable. It can only be
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi specified in conjunction
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi with <replaceable>\-\-clear-env</replaceable>, and can be
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi specified multiple times.
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH Yasufumi <replaceable>--clear-env</replaceable> を指定した際に、クリアせずに保持したままにしたい環境変数を指定します。<replaceable>--clear-env</replaceable> と同時にしか使えません。複数回指定できます。
9b9e2d5e20be33cb7534f3fedceb9e2a7e04dd43KATOH 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>
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH 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>
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH 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>
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH 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
a600d021adf34e58b3991269a9ceca3737c63aa8KATOH Yasufumi container requires a kernel of version 3.8 or higher, or a
a600d021adf34e58b3991269a9ceca3737c63aa8KATOH Yasufumi patched kernel, please see the lxc website for
57da8c32f85c0255efa61ee32e260068afdaa565KATOH Yasufumi details. <command>lxc-attach</command> will fail in that case if
a600d021adf34e58b3991269a9ceca3737c63aa8KATOH Yasufumi used with an unpatched kernel of version 3.7 and prior.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi (pid とマウント名前空間を含む) コンテナに対する完全なアタッチを行うには 3.8 以上、もしくはパッチを適用したカーネルが必要となります。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 詳しくは lxc のウェブサイトを参照してください。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi パッチが当たっていない 3.8 より小さなバージョンのカーネルを使った場合は、<command>lxc-attach</command> の実行は失敗するでしょう。
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>.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi しかし、もし <option>-s</option> を使用して、アタッチするものを <replaceable>NETWORK</replaceable>, <replaceable>IPC</replaceable>, <replaceable>UTSNAME</replaceable> の 1 つか複数の名前空間に限定して使用すれば、バージョン 3.0 以上のパッチを適用していないカーネルでもアタッチが成功するでしょう。
a600d021adf34e58b3991269a9ceca3737c63aa8KATOH Yasufumi Attaching to user namespaces is supported by kernel 3.8 or higher
a600d021adf34e58b3991269a9ceca3737c63aa8KATOH Yasufumi with enabling user namespace.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi ユーザ名前空間へのアタッチは、ユーザ名前空間機能を有効にした 3.8 以上のカーネルでサポートされます。
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>.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi Linux の <replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> ファイルシステムは名前空間によって影響を受けるある程度の情報を持っています。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi これは <replaceable>/proc</replaceable> 内のプロセス ID の名前のディレクトリや、<replaceable>/sys/class/net</replaceable> 内のネットワークインターフェース名のディレクトリなどです。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 擬似ファイルシステムをマウントしているプロセスの名前空間が、どのような情報を表示するかを決定します。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi <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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi <option>-s</option> を使ってコンテナの pid 名前空間のみをアタッチし、マウント名前空間 (これはコンテナの <replaceable>/proc</replaceable> を含み、ホストのは含まないでしょう) はアタッチしない場合、<option>/proc</option> のコンテンツはコンテナのものではなく、ホストのものとなります。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 似たような事例として、ネットワーク名前空間のみをアタッチして、<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>
e9555a6bc7056cd887ee19c80b6c59627ac61255Evgeni Golov does) before this is done, essentially 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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi この問題への対処のために、<option>-R</option> オプションが <replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> が提供されています。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi これにより、アタッチするプロセスのネットワーク/pid 名前空間のコンテキストを反映させることができます。ホストの実際のファイルシステムに影響を与えないために、実行前にはマウント名前空間は unshare されます (<command>lxc-unshare</command> のように)。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi これは、<replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> ファイルシステム以外はホストのマウント名前空間と同じである、新しいマウント名前空間がプロセスに与えられるということです。
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi Previous versions of <command>lxc-attach</command> suffered a bug whereby
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi a user could attach to a containers namespace without being placed in a
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi writeable cgroup for some critical subsystems. Newer versions of
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi <command>lxc-attach</command> will check whether a user is in a writeable
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi cgroup for those critical subsystems. <command>lxc-attach</command> might
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi thus fail unexpectedly for some users (E.g. on systems where an
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi unprivileged user is not placed in a writeable cgroup in critical
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi subsystems on login.). However, this behavior is correct and more secure.
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi 以前のバージョンの <command>lxc-attach</command> は、いくつかの重要なサブシステムに対して、書き込み可能な cgroup 内に配置することなしに、ユーザがコンテナの名前空間にアタッチできたバグがありました。
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi 新しいバージョンの <command>lxc-attach</command> は、このような重要なサブシステムに対して、ユーザが書き込み可能な cgroup 内にいるかどうかをチェックします。
b6acc629c0094fed0e451694e7a07a926847972bKATOH Yasufumi したがって、ユーザによっては <command>lxc-attach</command> は不意に失敗するかもしれません (例えば、非特権ユーザが、ログイン時に重要であるサブシステムの書き込み可能な cgroup に配置されていないようなシステムで)。しかし、この振る舞いは正しく、よりセキュアです。
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.
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi <option>-e</option> と <option>-s</option> オプションの使用には注意を払うべきです。
dc421f3aac1f0e516c763dd156629a8ed2a7b4caKATOH Yasufumi 不適切に使用した場合、コンテナの隔離を破壊してしまう可能性があります。
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