| 1 |
<!-- SPDX-License-Identifier: LGPL-2.1+ --> |
| 2 |
|
| 3 |
<!DOCTYPE refentry PUBLIC @docdtd@ [ |
| 4 |
|
| 5 |
<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml"> |
| 6 |
]> |
| 7 |
|
| 8 |
<refentry> |
| 9 |
|
| 10 |
<docinfo> |
| 11 |
<date>@LXC_GENERATE_DATE@</date> |
| 12 |
</docinfo> |
| 13 |
|
| 14 |
|
| 15 |
<refmeta> |
| 16 |
<refentrytitle>lxc</refentrytitle> |
| 17 |
<manvolnum>7</manvolnum> |
| 18 |
<refmiscinfo> |
| 19 |
Version @PACKAGE_VERSION@ |
| 20 |
</refmiscinfo> |
| 21 |
</refmeta> |
| 22 |
|
| 23 |
<refnamediv> |
| 24 |
<refname>lxc</refname> |
| 25 |
|
| 26 |
<refpurpose> |
| 27 |
<!-- |
| 28 |
linux containers |
| 29 |
--> |
| 30 |
Linux コンテナ |
| 31 |
</refpurpose> |
| 32 |
</refnamediv> |
| 33 |
|
| 34 |
<refsect1> |
| 35 |
<title><!-- Overview -->概要</title> |
| 36 |
<para> |
| 37 |
<!-- |
| 38 |
The container technology is actively being pushed into the mainstream |
| 39 |
Linux kernel. It provides resource management through control groups and |
| 40 |
resource isolation via namespaces. |
| 41 |
--> |
| 42 |
コンテナ技術は、メインストリームの Linux Kernel で活発に開発が進んでいる技術です。コンテナ技術は、cgroup によりリソースを管理する機能を提供し、名前空間によりリソースを隔離する機能を提供します。 |
| 43 |
</para> |
| 44 |
|
| 45 |
<para> |
| 46 |
<!-- |
| 47 |
<command>lxc</command>, aims to use these new functionalities to provide a |
| 48 |
userspace container object which provides full resource isolation and |
| 49 |
resource control for an applications or a full system. |
| 50 |
--> |
| 51 |
<command>lxc</command> は、アプリケーションまたはシステムのために完全なリソースの隔離やコントロールを提供する、ユーザースペースのコンテナオブジェクトを提供するためのこれらの新しい機能を使う事を目指しています。 |
| 52 |
</para> |
| 53 |
|
| 54 |
<para> |
| 55 |
<!-- |
| 56 |
<command>lxc</command> is small enough to easily manage a container with |
| 57 |
simple command lines and complete enough to be used for other purposes. |
| 58 |
--> |
| 59 |
<command>lxc</command> は、シンプルなコマンドラインでコンテナを簡単に管理できるほど軽量で、他の用途に使うのにも十分に機能がそろっています。 |
| 60 |
</para> |
| 61 |
</refsect1> |
| 62 |
|
| 63 |
<refsect1> |
| 64 |
<title><!-- Requirements -->動作条件</title> |
| 65 |
<para> |
| 66 |
<!-- |
| 67 |
The kernel version >= 3.10 shipped with the distros, will work with |
| 68 |
<command>lxc</command>, this one will have less functionalities but enough |
| 69 |
to be interesting. |
| 70 |
--> |
| 71 |
カーネルのバージョンが 3.10 以上のディストリビューションであれば、<command>lxc</command> が動作するでしょう。このバージョンは機能は少ないですが、それでも十分楽しめるでしょう。 |
| 72 |
</para> |
| 73 |
|
| 74 |
<para> |
| 75 |
<!-- |
| 76 |
<command>lxc</command> relies on a set of functionalities provided by the |
| 77 |
kernel. The helper script <command>lxc-checkconfig</command> will give |
| 78 |
you information about your kernel configuration, required, and missing |
| 79 |
features. |
| 80 |
--> |
| 81 |
<command>lxc</command> はカーネルが提供する様々な機能に依存します。<command>lxc-checkconfig</command> がカーネルの設定や、必要な機能、足りない機能についての情報を提供してくれるでしょう。 |
| 82 |
</para> |
| 83 |
</refsect1> |
| 84 |
|
| 85 |
<refsect1> |
| 86 |
<title><!-- Functional specification -->機能仕様</title> |
| 87 |
<para> |
| 88 |
<!-- |
| 89 |
A container is an object isolating some resources of the host, for the |
| 90 |
application or system running in it. |
| 91 |
--> |
| 92 |
コンテナは、ホストのリソースのいくつかを隔離して、内部でアプリケーションやシステムを実行します。 |
| 93 |
</para> |
| 94 |
<para> |
| 95 |
<!-- |
| 96 |
The application / system will be launched inside a container specified by |
| 97 |
a configuration that is either initially created or passed as a parameter |
| 98 |
of the commands. |
| 99 |
--> |
| 100 |
アプリケーションやシステムは、あらかじめ作成した設定や、コマンドへのパラメータで与えた設定で、コンテナ内で実行されます。 |
| 101 |
</para> |
| 102 |
|
| 103 |
<para> |
| 104 |
<!-- |
| 105 |
How to run an application in a container |
| 106 |
--> |
| 107 |
コンテナ内でアプリケーションを実行する方法 |
| 108 |
</para> |
| 109 |
<para> |
| 110 |
<!-- |
| 111 |
Before running an application, you should know what are the resources you |
| 112 |
want to isolate. The default configuration is to isolate PIDs, the sysv |
| 113 |
IPC and mount points. If you want to run a simple shell inside a |
| 114 |
container, a basic configuration is needed, especially if you want to |
| 115 |
share the rootfs. If you want to run an application like |
| 116 |
<command>sshd</command>, you should provide a new network stack and a new |
| 117 |
hostname. If you want to avoid conflicts with some files eg. |
| 118 |
<filename>/var/run/httpd.pid</filename>, you should remount |
| 119 |
<filename>/var/run</filename> with an empty directory. If you want to |
| 120 |
avoid the conflicts in all the cases, you can specify a rootfs for the |
| 121 |
container. The rootfs can be a directory tree, previously bind mounted |
| 122 |
with the initial rootfs, so you can still use your distro but with your |
| 123 |
own <filename>/etc</filename> and <filename>/home</filename> |
| 124 |
--> |
| 125 |
アプリケーションを実行する前に、隔離したいリソースについて知っておくべきです。デフォルトの設定では、PID、sysv IPC、マウントポイントが隔離されます。コンテナ内でシンプルなシェルを実行したい場合で、特に rootfs を共有したい場合、基本的な設定が必要です。 |
| 126 |
もし、<command>sshd</command> のようなアプリケーションを実行したい場合、新しいネットワークスタックと、新しいホスト名を準備しなくてはなりません。もし、同じファイル (<filename>/var/run/httpd.pid</filename> 等) の衝突を避けたい場合、空の <filename>/var/run/</filename> を再度マウントしなければなりません。 |
| 127 |
どんな場合でも衝突を避けたい場合、コンテナ専用の rootfs を指定することができます。rootfs はディレクトリツリーとする事も可能で、前もって元の rootfs を bind マウントし、<filename>/etc</filename> や <filename>/home</filename>だけは自身のディレクトリを使って、自身のディストリビューションを使えます。 |
| 128 |
</para> |
| 129 |
<para> |
| 130 |
<!-- |
| 131 |
Here is an example of directory tree |
| 132 |
for <command>sshd</command>: |
| 133 |
<programlisting> |
| 134 |
[root@lxc sshd]$ tree -d rootfs |
| 135 |
|
| 136 |
rootfs |
| 137 |
|-- bin |
| 138 |
|-- dev |
| 139 |
| |-- pts |
| 140 |
| `-- shm |
| 141 |
| `-- network |
| 142 |
|-- etc |
| 143 |
| `-- ssh |
| 144 |
|-- lib |
| 145 |
|-- proc |
| 146 |
|-- root |
| 147 |
|-- sbin |
| 148 |
|-- sys |
| 149 |
|-- usr |
| 150 |
`-- var |
| 151 |
|-- empty |
| 152 |
| `-- sshddd |
| 153 |
|-- lib |
| 154 |
| `-- empty |
| 155 |
| `-- sshd |
| 156 |
`-- run |
| 157 |
`-- sshd |
| 158 |
</programlisting> |
| 159 |
|
| 160 |
and the mount points file associated with it: |
| 161 |
<programlisting> |
| 162 |
[root@lxc sshd]$ cat fstab |
| 163 |
|
| 164 |
/lib /home/root/sshd/rootfs/lib none ro,bind 0 0 |
| 165 |
/bin /home/root/sshd/rootfs/bin none ro,bind 0 0 |
| 166 |
/usr /home/root/sshd/rootfs/usr none ro,bind 0 0 |
| 167 |
/sbin /home/root/sshd/rootfs/sbin none ro,bind 0 0 |
| 168 |
</programlisting> |
| 169 |
--> |
| 170 |
ここで、<command>sshd</command> のためのディレクトリツリーのサンプルを示しましょう。 |
| 171 |
<programlisting> |
| 172 |
[root@lxc sshd]$ tree -d rootfs |
| 173 |
|
| 174 |
rootfs |
| 175 |
|-- bin |
| 176 |
|-- dev |
| 177 |
| |-- pts |
| 178 |
| `-- shm |
| 179 |
| `-- network |
| 180 |
|-- etc |
| 181 |
| `-- ssh |
| 182 |
|-- lib |
| 183 |
|-- proc |
| 184 |
|-- root |
| 185 |
|-- sbin |
| 186 |
|-- sys |
| 187 |
|-- usr |
| 188 |
`-- var |
| 189 |
|-- empty |
| 190 |
| `-- sshd |
| 191 |
|-- lib |
| 192 |
| `-- empty |
| 193 |
| `-- sshd |
| 194 |
`-- run |
| 195 |
`-- sshd |
| 196 |
</programlisting> |
| 197 |
|
| 198 |
そして、それに対応するマウントポイントのファイルは以下のようになります。 |
| 199 |
<programlisting> |
| 200 |
[root@lxc sshd]$ cat fstab |
| 201 |
|
| 202 |
/lib /home/root/sshd/rootfs/lib none ro,bind 0 0 |
| 203 |
/bin /home/root/sshd/rootfs/bin none ro,bind 0 0 |
| 204 |
/usr /home/root/sshd/rootfs/usr none ro,bind 0 0 |
| 205 |
/sbin /home/root/sshd/rootfs/sbin none ro,bind 0 0 |
| 206 |
</programlisting> |
| 207 |
</para> |
| 208 |
|
| 209 |
<para> |
| 210 |
<!-- |
| 211 |
How to run a system in a container |
| 212 |
--> |
| 213 |
コンテナ内でシステムを実行する方法 |
| 214 |
</para> |
| 215 |
|
| 216 |
<para> |
| 217 |
<!-- |
| 218 |
Running a system inside a container is paradoxically easier |
| 219 |
than running an application. Why? Because you don't have to care |
| 220 |
about the resources to be isolated, everything needs to be |
| 221 |
isolated, the other resources are specified as being isolated but |
| 222 |
without configuration because the container will set them |
| 223 |
up. eg. the ipv4 address will be setup by the system container |
| 224 |
init scripts. Here is an example of the mount points file: |
| 225 |
--> |
| 226 |
コンテナ内でシステムを実行するのは、逆説的ではありますが、アプリケーションを実行するよりも簡単です。 |
| 227 |
それは、隔離するリソースについて考える必要がないからで、全てを隔離する必要があるからです。 |
| 228 |
他のリソースは、コンテナが設定を行うので、設定なしで隔離されるように指定されます。 |
| 229 |
例えば、IPv4 アドレスはコンテナの init スクリプトでシステムによってセットアップされるでしょう。 |
| 230 |
以下に、(システムを実行するときの) マウントポイントファイルを示します。 |
| 231 |
</para> |
| 232 |
|
| 233 |
<programlisting> |
| 234 |
[root@lxc debian]$ cat fstab |
| 235 |
|
| 236 |
/dev /home/root/debian/rootfs/dev none bind 0 0 |
| 237 |
/dev/pts /home/root/debian/rootfs/dev/pts none bind 0 0 |
| 238 |
</programlisting> |
| 239 |
|
| 240 |
<refsect2> |
| 241 |
<title><!-- Container life cycle -->コンテナのライフサイクル</title> |
| 242 |
<para> |
| 243 |
<!-- |
| 244 |
When the container is created, it contains the configuration |
| 245 |
information. When a process is launched, the container will be starting |
| 246 |
and running. When the last process running inside the container exits, |
| 247 |
the container is stopped. |
| 248 |
--> |
| 249 |
コンテナが作成されるとき、コンテナは設定情報を含みます。プロセスが生成されるとき、コンテナは開始し、実行されるでしょう。コンテナ内で実行されている最後のプロセスが終了したとき、コンテナは停止します。 |
| 250 |
</para> |
| 251 |
<para> |
| 252 |
<!-- |
| 253 |
In case of failure when the container is initialized, it will pass |
| 254 |
through the aborting state. |
| 255 |
--> |
| 256 |
コンテナの初期化時の失敗の場合は、(以下の図の) 中断の状態を通ります。 |
| 257 |
</para> |
| 258 |
|
| 259 |
<programlisting> |
| 260 |
<![CDATA[ |
| 261 |
--------- |
| 262 |
| STOPPED |<--------------- |
| 263 |
--------- | |
| 264 |
| | |
| 265 |
start | |
| 266 |
| | |
| 267 |
V | |
| 268 |
---------- | |
| 269 |
| STARTING |--error- | |
| 270 |
---------- | | |
| 271 |
| | | |
| 272 |
V V | |
| 273 |
--------- ---------- | |
| 274 |
| RUNNING | | ABORTING | | |
| 275 |
--------- ---------- | |
| 276 |
| | | |
| 277 |
no process | | |
| 278 |
| | | |
| 279 |
V | | |
| 280 |
---------- | | |
| 281 |
| STOPPING |<------- | |
| 282 |
---------- | |
| 283 |
| | |
| 284 |
--------------------- |
| 285 |
]]> |
| 286 |
</programlisting> |
| 287 |
</refsect2> |
| 288 |
|
| 289 |
<refsect2> |
| 290 |
<title><!-- Configuration -->設定</title> |
| 291 |
<para> |
| 292 |
<!-- |
| 293 |
The container is configured through a configuration |
| 294 |
file, the format of the configuration file is described in |
| 295 |
<citerefentry> |
| 296 |
<refentrytitle><filename>lxc.conf</filename></refentrytitle> |
| 297 |
<manvolnum>5</manvolnum> |
| 298 |
</citerefentry> |
| 299 |
--> |
| 300 |
</para> |
| 301 |
コンテナは設定ファイル経由で設定します。設定の書式は |
| 302 |
<citerefentry> |
| 303 |
<refentrytitle><filename>lxc.conf</filename></refentrytitle> |
| 304 |
<manvolnum>5</manvolnum> |
| 305 |
</citerefentry> |
| 306 |
で説明しています。 |
| 307 |
</refsect2> |
| 308 |
|
| 309 |
<refsect2> |
| 310 |
<title><!-- Unprivileged containers -->非特権コンテナ</title> |
| 311 |
<para> |
| 312 |
<!-- |
| 313 |
Unprivileged LXC containers run without root host-level privileges in a |
| 314 |
user namespace, mapping container UID 0 to a non-root host ID, which |
| 315 |
strictly limits the accessible devices and filesystems of the |
| 316 |
container. In order to mount a rootfs in an unprivileged container, the |
| 317 |
mapped host user must have execute permissions for all directories |
| 318 |
along the path to and including the rootfs. Additionally, all files and |
| 319 |
directories under the rootfs must be owned by the correct user ID and |
| 320 |
group ID. The correct user ID and group ID are the host IDs mapped to |
| 321 |
the container root(UID 0) in lxc.idmap. |
| 322 |
--> |
| 323 |
非特権 LXC コンテナは、ユーザ名前空間内で root のホストレベルの特権がない状態で実行されます。コンテナの UID 0 は、root ではないホストの ID にマッピングされ、コンテナのアクセス可能なデバイスとファイルシステムが厳密に制限されます。非特権コンテナ内で rootfs をマウントするためには、マッピングされたホストのユーザが、rootfs ディレクトリ自身を含む、rootfs までのパス上にあるすべてのディレクトリに対して実行権限を持っている必要があります。さらに、rootfs 以下のすべてのファイルとディレクトリは、正しいユーザ ID とグループ ID が所有している必要があります。正しいユーザ ID とグループ ID とは、lxc.idmap でコンテナの root(UID 0)にマッピングされているホストの ID です。 |
| 324 |
</para> |
| 325 |
</refsect2> |
| 326 |
|
| 327 |
<refsect2> |
| 328 |
<title><!-- Creating / Destroying containers -->コンテナの作成と削除</title> |
| 329 |
<para> |
| 330 |
<!-- |
| 331 |
A persistent container object can be created via the |
| 332 |
<command>lxc-create</command> command. It takes a container name as |
| 333 |
parameter and optional configuration file and template. The name is |
| 334 |
used by the different commands to refer to this container. The |
| 335 |
<command>lxc-destroy</command> command will destroy the container |
| 336 |
object. |
| 337 |
--> |
| 338 |
持続性のコンテナオブジェクトは <command>lxc-create</command> コマンドで作成できます。コマンドにはコンテナ名をパラメータとして与え、オプションで設定ファイルとテンプレートを指定します。ここで指定する名前は、他のコマンドからこのコンテナを参照する際に使います。 |
| 339 |
<command>lxc-destroy</command> コマンドはコンテナオブジェクトを削除します。 |
| 340 |
<programlisting> |
| 341 |
lxc-create -n foo |
| 342 |
lxc-destroy -n foo |
| 343 |
</programlisting> |
| 344 |
</para> |
| 345 |
</refsect2> |
| 346 |
|
| 347 |
<refsect2> |
| 348 |
<title><!-- Volatile container -->一時的な (揮発性の) コンテナ</title> |
| 349 |
<para> |
| 350 |
<!-- |
| 351 |
It is not mandatory to create a container object before starting it. |
| 352 |
The container can be directly started with a configuration file as |
| 353 |
parameter. |
| 354 |
--> |
| 355 |
コンテナを開始する前にコンテナオブジェクトを作成する必要はありません。パラメータとして設定ファイルを指定して、コンテナを直接起動できます。 |
| 356 |
</para> |
| 357 |
</refsect2> |
| 358 |
|
| 359 |
<refsect2> |
| 360 |
<title><!-- Starting / Stopping container -->コンテナの起動と停止</title> |
| 361 |
<para> |
| 362 |
<!-- |
| 363 |
When the container has been created, it is ready to run an application / |
| 364 |
system. This is the purpose of the <command>lxc-execute</command> and |
| 365 |
<command>lxc-start</command> commands. If the container was not created |
| 366 |
before starting the application, the container will use the |
| 367 |
configuration file passed as parameter to the command, and if there is |
| 368 |
no such parameter either, then it will use a default isolation. If the |
| 369 |
application ended, the container will be stopped, but if needed the |
| 370 |
<command>lxc-stop</command> command can be used to stop the container. |
| 371 |
--> |
| 372 |
コンテナが作成されると、アプリケーションもしくはシステムを実行できます。このために使用するのが <command>lxc-execute</command> と <command>lxc-start</command> コマンドです。 |
| 373 |
アプリケーションを開始する前にコンテナを作成しなかった場合、コンテナはコマンドにパラメータとして渡した設定ファイルを使用します。もし、このようなパラメータもない場合は、デフォルトで指定されている通りに隔離されます。 |
| 374 |
アプリケーションが終了した場合、コンテナも停止します。<command>lxc-stop</command> コマンドを使って、実行中のアプリケーションを停止することもできます。 |
| 375 |
</para> |
| 376 |
|
| 377 |
<para> |
| 378 |
<!-- |
| 379 |
Running an application inside a container is not exactly the same thing |
| 380 |
as running a system. For this reason, there are two different commands |
| 381 |
to run an application into a container: |
| 382 |
--> |
| 383 |
コンテナ内でアプリケーションを実行することは、正確にはシステムとして実行するのとは異なります。このため、コンテナ内でアプリケーションを実行するためのコマンドには、2 種類の違ったものがあります。 |
| 384 |
<programlisting> |
| 385 |
lxc-execute -n foo [-f config] /bin/bash |
| 386 |
lxc-start -n foo [-f config] [/bin/bash] |
| 387 |
</programlisting> |
| 388 |
</para> |
| 389 |
|
| 390 |
<para> |
| 391 |
<!-- |
| 392 |
The <command>lxc-execute</command> command will run the specified command |
| 393 |
into a container via an intermediate process, |
| 394 |
<command>lxc-init</command>. |
| 395 |
This lxc-init after launching the specified command, will wait for its |
| 396 |
end and all other reparented processes. (to support daemons in the |
| 397 |
container). In other words, in the container, |
| 398 |
<command>lxc-init</command> has PID 1 and the first process of the |
| 399 |
application has PID 2. |
| 400 |
--> |
| 401 |
<command>lxc-execute</command> コマンドは、間に <command>lxc-init</command> プロセスを介して、コンテナ内で指定したコマンドを実行します。 |
| 402 |
lxc-init はコマンドを実行した後、(コンテナ内でのデーモンの実行をサポートするために) 実行したコマンドと生成された全てのプロセスが終了するのを待ちます。 |
| 403 |
言いかえると、コンテナ内では <command>lxc-init</command> は PID 1 を持ち、アプリケーションの最初のプロセスは PID 2 をもちます。 |
| 404 |
</para> |
| 405 |
|
| 406 |
<para> |
| 407 |
<!-- |
| 408 |
The <command>lxc-start</command> command will directly run the specified |
| 409 |
command in the container. The PID of the first process is 1. If no |
| 410 |
command is specified <command>lxc-start</command> will run the command |
| 411 |
defined in lxc.init.cmd or if not set, <filename>/sbin/init</filename> . |
| 412 |
--> |
| 413 |
<command>lxc-start</command> コマンドは、コンテナ内の特定のコマンドを直接実行します。最初のプロセスの PID が 1 となります。 |
| 414 |
もし、実行するコマンドが指定されていない場合は、<command>lxc-start</command> は lxc.init.cmd で設定されたコマンドを実行します。もし lxc.init.cmd が設定されていない場合は <filename>/sbin/init</filename> を実行します。 |
| 415 |
</para> |
| 416 |
|
| 417 |
<para> |
| 418 |
<!-- |
| 419 |
To summarize, <command>lxc-execute</command> is for running an |
| 420 |
application and <command>lxc-start</command> is better suited for |
| 421 |
running a system. |
| 422 |
--> |
| 423 |
まとめると、<command>lxc-execute</command> はアプリケーションを実行するためのコマンドであり、<command>lxc-start</command> はシステムを実行するのにより適したコマンドです。 |
| 424 |
</para> |
| 425 |
|
| 426 |
<para> |
| 427 |
<!-- |
| 428 |
If the application is no longer responding, is inaccessible or is not |
| 429 |
able to finish by itself, a wild <command>lxc-stop</command> command |
| 430 |
will kill all the processes in the container without pity. |
| 431 |
--> |
| 432 |
もしアプリケーションの反応がなくなった場合や、アクセスできなくなった場合、自分で終了できない場合は、荒っぽいですが、<command>lxc-stop</command> コマンドがコンテナ内の全てのプロセスを容赦なく停止させてくれるでしょう。 |
| 433 |
<programlisting> |
| 434 |
lxc-stop -n foo -k |
| 435 |
</programlisting> |
| 436 |
|
| 437 |
</para> |
| 438 |
</refsect2> |
| 439 |
|
| 440 |
<refsect2> |
| 441 |
<title><!-- Connect to an available tty -->利用可能な tty への接続</title> |
| 442 |
<para> |
| 443 |
<!-- |
| 444 |
If the container is configured with ttys, it is possible to access it |
| 445 |
through them. It is up to the container to provide a set of available |
| 446 |
ttys to be used by the following command. When the tty is lost, it is |
| 447 |
possible to reconnect to it without login again. |
| 448 |
--> |
| 449 |
コンテナが tty を持つように設定されているならば、tty を通してコンテナにアクセスすることができます。 |
| 450 |
アクセスできるかどうかは、以下のコマンドが使う tty がコンテナで利用できるように設定されているか次第です。 |
| 451 |
tty が失われたとき、再度のログインなしでその tty に再接続することが可能です。 |
| 452 |
<programlisting> |
| 453 |
lxc-console -n foo -t 3 |
| 454 |
</programlisting> |
| 455 |
</para> |
| 456 |
</refsect2> |
| 457 |
|
| 458 |
<refsect2> |
| 459 |
<title><!-- Freeze / Unfreeze container -->コンテナの凍結と解凍</title> |
| 460 |
<para> |
| 461 |
<!-- |
| 462 |
Sometime, it is useful to stop all the processes belonging to |
| 463 |
a container, eg. for job scheduling. The commands: |
| 464 |
<programlisting> |
| 465 |
lxc-freeze -n foo |
| 466 |
</programlisting> |
| 467 |
|
| 468 |
will put all the processes in an uninteruptible state and |
| 469 |
|
| 470 |
<programlisting> |
| 471 |
lxc-unfreeze -n foo |
| 472 |
</programlisting> |
| 473 |
|
| 474 |
will resume them. |
| 475 |
--> |
| 476 |
ジョブスケジューリングなどで、コンテナに属する全てのプロセスを停止する事が役に立つときがあります。 |
| 477 |
コマンド |
| 478 |
<programlisting> |
| 479 |
lxc-freeze -n foo |
| 480 |
</programlisting> |
| 481 |
は、全てのプロセスを中断不可能な状態に置きます。そして、 |
| 482 |
|
| 483 |
<programlisting> |
| 484 |
lxc-unfreeze -n foo |
| 485 |
</programlisting> |
| 486 |
|
| 487 |
その全てのプロセスを再開します。 |
| 488 |
</para> |
| 489 |
|
| 490 |
<para> |
| 491 |
<!-- |
| 492 |
This feature is enabled if the freezer cgroup v1 controller is enabled |
| 493 |
in the kernel. |
| 494 |
--> |
| 495 |
この機能は、カーネルで cgroup v1 の freezer コントローラが有効になっている場合に使用できます。 |
| 496 |
</para> |
| 497 |
</refsect2> |
| 498 |
|
| 499 |
<refsect2> |
| 500 |
<title><!-- Getting information about container --> |
| 501 |
コンテナに関する情報の取得</title> |
| 502 |
<para> |
| 503 |
<!-- |
| 504 |
When there are a lot of containers, it is hard to follow what has been |
| 505 |
created or destroyed, what is running or what are the PIDs running in a |
| 506 |
specific container. For this reason, the following commands may be useful: |
| 507 |
--> |
| 508 |
多数のコンテナが存在する場合、それらが実行されたり削除されたりすること、何が実行されていて、特定のコンテナ内で実行されている PID が何であるかをフォローするのは大変です。このような時には、以下のようなコマンドが役に立つかもしれません。 |
| 509 |
<programlisting> |
| 510 |
lxc-ls -f |
| 511 |
lxc-info -n foo |
| 512 |
</programlisting> |
| 513 |
</para> |
| 514 |
<para> |
| 515 |
<!-- |
| 516 |
<command>lxc-ls</command> lists containers. |
| 517 |
--> |
| 518 |
<command>lxc-ls</command> はコンテナをリスト表示します。 |
| 519 |
</para> |
| 520 |
|
| 521 |
<para> |
| 522 |
<!-- |
| 523 |
<command>lxc-info</command> gives information for a specific container. |
| 524 |
--> |
| 525 |
<command>lxc-info</command> は、指定したコンテナに関する情報を表示します。 |
| 526 |
</para> |
| 527 |
|
| 528 |
<para> |
| 529 |
<!-- |
| 530 |
Here is an example on how the combination of these commands |
| 531 |
allows one to list all the containers and retrieve their state. |
| 532 |
--> |
| 533 |
ここで、以上のコマンドを組み合わせて、どのようにしたら全てのコンテナのリストと、それぞれの状態が得られるかの例を示します。 |
| 534 |
<programlisting> |
| 535 |
for i in $(lxc-ls -1); do |
| 536 |
lxc-info -n $i |
| 537 |
done |
| 538 |
</programlisting> |
| 539 |
</para> |
| 540 |
|
| 541 |
</refsect2> |
| 542 |
|
| 543 |
<refsect2> |
| 544 |
<title><!-- Monitoring container -->コンテナのモニタリング</title> |
| 545 |
<para> |
| 546 |
<!-- |
| 547 |
It is sometime useful to track the states of a container, for example to |
| 548 |
monitor it or just to wait for a specific state in a script. |
| 549 |
--> |
| 550 |
時々、コンテナの状態を追跡することが出来ると便利な事があります。例えば、状態をモニタリングしたり、スクリプト内で特定の状態を待ったりするような場合です。 |
| 551 |
</para> |
| 552 |
|
| 553 |
<para> |
| 554 |
<!-- |
| 555 |
<command>lxc-monitor</command> command will monitor one or several |
| 556 |
containers. The parameter of this command accepts a regular expression |
| 557 |
for example: |
| 558 |
--> |
| 559 |
<command>lxc-monitor</command> コマンドは、一つもしくは複数のコンテナをモニタリングします。このコマンドのパラメータは、正規表現を受け付けます。例えば |
| 560 |
<programlisting> |
| 561 |
lxc-monitor -n "foo|bar" |
| 562 |
</programlisting> |
| 563 |
<!-- |
| 564 |
will monitor the states of containers named 'foo' and 'bar', and: |
| 565 |
--> |
| 566 |
は 'foo' と 'bar' という名前のコンテナの状態をモニタリングします。そして、 |
| 567 |
<programlisting> |
| 568 |
lxc-monitor -n ".*" |
| 569 |
</programlisting> |
| 570 |
<!-- |
| 571 |
will monitor all the containers. |
| 572 |
--> |
| 573 |
は全てのコンテナの状態をモニタリングします。 |
| 574 |
</para> |
| 575 |
<para> |
| 576 |
<!-- |
| 577 |
For a container 'foo' starting, doing some work and exiting, |
| 578 |
the output will be in the form: |
| 579 |
--> |
| 580 |
コンテナ 'foo' が開始され、いくつか処理を行い、終了した場合、出力は以下のようになります。 |
| 581 |
<programlisting> |
| 582 |
'foo' changed state to [STARTING] |
| 583 |
'foo' changed state to [RUNNING] |
| 584 |
'foo' changed state to [STOPPING] |
| 585 |
'foo' changed state to [STOPPED] |
| 586 |
</programlisting> |
| 587 |
</para> |
| 588 |
<para> |
| 589 |
<!-- |
| 590 |
<command>lxc-wait</command> command will wait for a specific |
| 591 |
state change and exit. This is useful for scripting to |
| 592 |
synchronize the launch of a container or the end. The |
| 593 |
parameter is an ORed combination of different states. The |
| 594 |
following example shows how to wait for a container if it successfully |
| 595 |
started as a daemon. |
| 596 |
--> |
| 597 |
<command>lxc-wait</command> コマンドは指定した状態を待って終了します。これは、コンテナの開始や終了に同期したいスクリプトで役に立ちます。パラメータは、異なった状態の論理和 (OR) を指定します。 |
| 598 |
以下の例は、バックグラウンドで実行されたコンテナをどのようにして待つかを示します。 |
| 599 |
|
| 600 |
<programlisting> |
| 601 |
<![CDATA[ |
| 602 |
# launch lxc-wait in background |
| 603 |
lxc-wait -n foo -s STOPPED & |
| 604 |
LXC_WAIT_PID=$! |
| 605 |
|
| 606 |
# this command goes in background |
| 607 |
lxc-execute -n foo mydaemon & |
| 608 |
|
| 609 |
# block until the lxc-wait exits |
| 610 |
# and lxc-wait exits when the container |
| 611 |
# is STOPPED |
| 612 |
wait $LXC_WAIT_PID |
| 613 |
echo "'foo' is finished" |
| 614 |
]]> |
| 615 |
</programlisting> |
| 616 |
</para> |
| 617 |
</refsect2> |
| 618 |
|
| 619 |
<refsect2> |
| 620 |
<title><!-- cgroup settings for containers -->コンテナの cgroup の設定</title> |
| 621 |
<para> |
| 622 |
<!-- |
| 623 |
The container is tied with the control groups, when a container is |
| 624 |
started a control group is created and associated with it. The control |
| 625 |
group properties can be read and modified when the container is running |
| 626 |
by using the lxc-cgroup command. |
| 627 |
--> |
| 628 |
コンテナは control group と結合しています。コンテナを開始すると cgroup が生成され、結びつけられます。 |
| 629 |
cgroup のプロパティは、lxc-cgroup コマンドを使って、コンテナが実行中に読み取ったり変更したりできます。 |
| 630 |
</para> |
| 631 |
<para> |
| 632 |
<!-- |
| 633 |
<command>lxc-cgroup</command> command is used to set or get a |
| 634 |
control group subsystem which is associated with a |
| 635 |
container. The subsystem name is handled by the user, the |
| 636 |
command won't do any syntax checking on the subsystem name, if |
| 637 |
the subsystem name does not exists, the command will fail. |
| 638 |
--> |
| 639 |
<command>lxc-cgroup</command> コマンドは、コンテナと結びつけられている control group サブシステムを設定したり、取得したりするのに使います。サブシステム名の指定はユーザが行ない、このコマンドはサブシステム名の文法チェックは一切行ないません。もし、指定したサブシステム名が存在しない場合は、コマンドの実行は失敗します。 |
| 640 |
</para> |
| 641 |
<para> |
| 642 |
<programlisting> |
| 643 |
lxc-cgroup -n foo cpuset.cpus |
| 644 |
</programlisting> |
| 645 |
<!-- |
| 646 |
will display the content of this subsystem. |
| 647 |
--> |
| 648 |
は、このサブシステムの内容を表示します。 |
| 649 |
<programlisting> |
| 650 |
lxc-cgroup -n foo cpu.shares 512 |
| 651 |
</programlisting> |
| 652 |
<!-- |
| 653 |
will set the subsystem to the specified value. |
| 654 |
--> |
| 655 |
は、このサブシステムに指定した値を設定します。 |
| 656 |
</para> |
| 657 |
</refsect2> |
| 658 |
</refsect1> |
| 659 |
|
| 660 |
&seealso; |
| 661 |
|
| 662 |
</refentry> |
| 663 |
|
| 664 |
<!-- Keep this comment at the end of the file Local variables: mode: |
| 665 |
sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil |
| 666 |
sgml-always-quote-attributes:t sgml-indent-step:2 sgml-indent-data:t |
| 667 |
sgml-parent-document:nil sgml-default-dtd-file:nil |
| 668 |
sgml-exposed-tags:nil sgml-local-catalogs:nil |
| 669 |
sgml-local-ecat-files:nil End: --> |