lxc-attach.sgml.in revision 1b29d73cba7a54227f937969de05fc0cfa07580a
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainenlxc: linux Container library
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen(C) Copyright IBM Corp. 2007, 2008
e8490a52a1bc71bc53034e68f464435684ad810fTimo SirainenDaniel Lezcano <daniel.lezcano at free.fr>
e8490a52a1bc71bc53034e68f464435684ad810fTimo SirainenThis library is free software; you can redistribute it and/or
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainenmodify it under the terms of the GNU Lesser General Public
296dca49e4fe6046e0328c67ef1cf4b8077dec9cTimo SirainenLicense as published by the Free Software Foundation; either
296dca49e4fe6046e0328c67ef1cf4b8077dec9cTimo Sirainenversion 2.1 of the License, or (at your option) any later version.
296dca49e4fe6046e0328c67ef1cf4b8077dec9cTimo SirainenThis library is distributed in the hope that it will be useful,
32e1554df9abca74fef0af2ba2e4c37e90a06cd0Timo Sirainenbut WITHOUT ANY WARRANTY; without even the implied warranty of
4ac2d38239cea8090154e17faefd77de5a71d882Timo SirainenMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4ac2d38239cea8090154e17faefd77de5a71d882Timo SirainenLesser General Public License for more details.
4ac2d38239cea8090154e17faefd77de5a71d882Timo SirainenYou should have received a copy of the GNU Lesser General Public
32e1554df9abca74fef0af2ba2e4c37e90a06cd0Timo SirainenLicense along with this library; if not, write to the Free Software
32e1554df9abca74fef0af2ba2e4c37e90a06cd0Timo SirainenFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29e82a14501731bef8c41a1b27fc415d634fa01dTimo SirainenTranslated into Japanese
a988c3fd9251806e38931a011aaa4006dd081cbdTimo Sirainenby KATOH Yasufumi <karma at jazz.email.ne.jp>
296dca49e4fe6046e0328c67ef1cf4b8077dec9cTimo Sirainen<!ENTITY commonoptions SYSTEM "@builddir@/common_options.sgml">
296dca49e4fe6046e0328c67ef1cf4b8077dec9cTimo Sirainen<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen start a process inside a running container.
48a4fccfb24f81ee05ebc07b5db569c1fbf499c5Timo Sirainen 実行中のコンテナ内でプロセスの開始
48a4fccfb24f81ee05ebc07b5db569c1fbf499c5Timo Sirainen </refpurpose>
092018b35bb1dc5bd61848a38189fe6ac8f791ddTimo Sirainen </refnamediv>
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen <refsynopsisdiv>
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen <cmdsynopsis>
c8cf8a605e0ddea7cb36fe04551aeca5090e684bTimo Sirainen <arg choice="req">-n <replaceable>name</replaceable></arg>
c8cf8a605e0ddea7cb36fe04551aeca5090e684bTimo Sirainen <arg choice="opt">-a <replaceable>arch</replaceable></arg>
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen <arg choice="opt">-s <replaceable>namespaces</replaceable></arg>
ef50336eefcb9ba99f73c6af37420eaf8857a39bTimo Sirainen <arg choice="opt">-- <replaceable>command</replaceable></arg>
ef50336eefcb9ba99f73c6af37420eaf8857a39bTimo Sirainen </cmdsynopsis>
14376e0584c178306c400750352869cf2aaf6feeTimo Sirainen </refsynopsisdiv>
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen <command>lxc-attach</command> runs the specified
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen <replaceable>command</replaceable> inside the container
9874ad56b94788297fdac4eae7cba5d651b48222Timo Sirainen specified by <replaceable>name</replaceable>. The container
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen has to be running already.
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen <command>lxc-attach</command> は <replaceable>name</replaceable> で指定したコンテナ内で指定した <replaceable>command</replaceable> を実行します.実行する時点でコンテナが実行中でなければなりません.
32e1554df9abca74fef0af2ba2e4c37e90a06cd0Timo Sirainen If no <replaceable>command</replaceable> is specified, the
a988c3fd9251806e38931a011aaa4006dd081cbdTimo Sirainen current default shell of the user running
a988c3fd9251806e38931a011aaa4006dd081cbdTimo Sirainen <command>lxc-attach</command> will be looked up inside the
a988c3fd9251806e38931a011aaa4006dd081cbdTimo Sirainen container and executed. This will fail if no such user exists
a988c3fd9251806e38931a011aaa4006dd081cbdTimo Sirainen inside the container or the container does not have a working
957d09e495c33ad1180f82152e5e87e6b51ab04bTimo Sirainen nsswitch mechanism.
957d09e495c33ad1180f82152e5e87e6b51ab04bTimo Sirainen もし <replaceable>command</replaceable> が指定されていない場合,<command>lxc-attach</command> コマンドを実行したユーザのデフォルトシェルをコンテナ内で調べて実行します.もしコンテナ内にユーザが存在しない場合や,コンテナで nsswitch 機構が働いていない場合はこの動作は失敗します.
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen <variablelist>
957d09e495c33ad1180f82152e5e87e6b51ab04bTimo Sirainen <varlistentry>
957d09e495c33ad1180f82152e5e87e6b51ab04bTimo Sirainen <option>-a, --arch <replaceable>arch</replaceable></option>
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen Specify the architecture which the kernel should appear to be
same settings as the <option>lxc.arch</option> option in
<refentrytitle><filename>lxc.conf</filename></refentrytitle>
コマンドを実行するコンテナのアーキテクチャを指定します.このオプションは,コンテナの設定ファイルで指定する <option>lxc.arch</option> オプションと同じものとして受け入れられます.
コンテナの内部で <replaceable>command</replaceable> を実行する時に特権を削除しません.もしこのオプションが指定された場合,新しいプロセスはコンテナの cgroup に追加 <emphasis>されず</emphasis>,実行する前にケーパビリティ (capability) も削除しません.
them, as a pipe-separated list, e.g.
指定できる値は,それぞれ cgroup,ケーパビリティ,特権の制限を表す <replaceable>CGROUP</replaceable>,<replaceable>CAP</replaceable>,<replaceable>LSM</replaceable> です.
<emphasis>警告:</emphasis>もし実行するコマンドが,アタッチするメインプロセスが終了した後も実行されたままのサブプロセスを開始するような場合,このオプションの指定はコンテナ内への特権のリークとなる可能性があります.コンテナ内でのデーモンの開始(もしくは再起動)は問題となります.デーモンが多数のサブプロセスを開始する <command>cron</command> や <command>sshd</command> のような場合は特に問題となります.<emphasis>充分な注意を払って使用してください.</emphasis>
e.g. <replaceable>NETWORK|IPC</replaceable>. Allowed values are
the context of the process to e.g. the network namespace of the
アタッチする名前空間をパイプで連結したリストで指定します.例えば <replaceable>NETWORK|IPC</replaceable> のようにです.ここで使用可能な値は <replaceable>MOUNT</replaceable>, <replaceable>PID</replaceable>, <replaceable>UTSNAME</replaceable>, <replaceable>IPC</replaceable>, <replaceable>USER </replaceable>, <replaceable>NETWORK</replaceable> です.これにより指定した名前空間にプロセスのコンテキストを変更できます.例えばコンテナのネットワーク名前空間に変更する一方で,他の名前空間はホストの名前空間のままにするというような事が可能です.
<option>-s</option> を指定し,そこにマウント名前空間が含まれない時,このオプションにより <command>lxc-attach</command> は <replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> をリマウントします.これは現在の他の名前空間のコンテキストを反映させるためです.
アタッチされるプログラムに対して現在の環境を保持したままにします.これは現在 (バージョン 0.9 時点) のデフォルトの動作ですが,将来は変更される予定です.この動作がコンテナ内への望ましくない情報の漏洩につながる可能性があるためです.アタッチするプログラムで環境変数が利用可能であることを期待している場合,将来的にもそれが保証されるようにこのオプションを使用するようにしてください.現在の環境変数に加えて,container=lxc が設定されます.
NET_ADMIN ケーパビリティを持たない実行中のコンテナのネットワークインターフェース eth1 の動作を停止させるには,ケーパビリティを増加させるために <option>-e</option> オプションを指定し,<command>ip</command> ツールがインストールされていることを前提に,以下のように実行します.
(pid とマウント名前空間を含む) コンテナに対する完全なアタッチを行うにはパッチを適用したカーネルが必要となります.詳しくは lxc のウェブサイトを参照してください.(訳注: 3.8 カーネルから PID, マウント名前空間に対するアタッチも可能になっている)
しかし,もし <option>-s</option> を使用して,アタッチするものを <replaceable>NETWORK</replaceable>, <replaceable>IPC</replaceable>, <replaceable>UTSNAME</replaceable> の 1 つか複数の名前空間に限定して使用すれば,バージョン 3.0 以上のパッチを適用していないカーネルでもアタッチが成功するでしょう.
ユーザ名前空間へのアタッチは,現時点ではカーネルで完全にサポートされていません.しかし,<command>lxc-attach</command> は,将来のカーネルがこの機能を実装した時点ですぐに,アタッチが可能になるはずです.
Linux の <replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> ファイルシステムは名前空間によって影響を受けるいくつかの情報を持っています.これは <replaceable>/proc</replaceable> 内のプロセス ID の名前のディレクトリや,<replaceable>/sys/class/net</replaceable> 内のネットワークインターフェース名のディレクトリなどです.擬似ファイルシステムをマウントしているプロセスの名前空間が,どのような情報を表示するかを決定します.<replaceable>/proc</replaceable> や <replaceable>/sys</replaceable> にアクセスしているプロセスの名前空間が決定するのではありません.
<option>-s</option> を使ってコンテナの pid 名前空間のみをアタッチし,マウント名前空間 (これはコンテナの <replaceable>/proc</replaceable> を含み,ホストのは含まないでしょう) はアタッチしない場合,<option>/proc</option> のコンテンツはコンテナのものではなく,ホストのものとなります.似たような事例として,ネットワーク名前空間のみをアタッチして,<replaceable>/sys/class/net</replaceable> のコンテンツを読んだ場合も同じような事が起こるでしょう.
この問題への対処のために,<option>-R</option> オプションが <replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> が提供されています.これにより,アタッチするプロセスのネットワーク/pid 名前空間のコンテキストを反映させることができます.ホストの実際のファイルシステムに影響を与えないために,実行前にはマウント名前空間は unshare されます (<command>lxc-unshare</command> のように).これは,<replaceable>/proc</replaceable> と <replaceable>/sys</replaceable> ファイルシステム以外はホストのマウント名前空間と同じである,新しいマウント名前空間がプロセスに与えられるということです.