| 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><!-- Quick start -->빠른 도움말</title> |
| 36 |
<para> |
| 37 |
<!-- |
| 38 |
You are in a hurry, and you don't want to read this man page. Ok, |
| 39 |
without warranty, here are the commands to launch a shell inside |
| 40 |
a container with a predefined configuration template, it may |
| 41 |
work. |
| 42 |
<command>@BINDIR@/lxc-execute -n foo -f |
| 43 |
@DOCDIR@/examples/lxc-macvlan.conf /bin/bash</command> |
| 44 |
--> |
| 45 |
man 페이지를 읽고 싶지는 않지만 서둘러서 해보고 싶다면, |
| 46 |
된다고 보장할 수는 없지만, 미리정의된 설정파일로 컨테이너 내에서 쉘을 실행하는 아래 명령어를 소개하고자 한다. |
| 47 |
|
| 48 |
<command>@BINDIR@/lxc-execute -n foo -f |
| 49 |
@DOCDIR@/examples/lxc-macvlan.conf /bin/bash</command> |
| 50 |
</para> |
| 51 |
</refsect1> |
| 52 |
|
| 53 |
<refsect1> |
| 54 |
<title><!-- Overview -->개요</title> |
| 55 |
<para> |
| 56 |
<!-- |
| 57 |
The container technology is actively being pushed into the |
| 58 |
mainstream linux kernel. It provides the resource management |
| 59 |
through the control groups aka process containers and resource |
| 60 |
isolation through the namespaces. |
| 61 |
--> |
| 62 |
컨테이너 기술은 리눅스 커널의 메인스트림에서 활발하게 개발이 진행되고 있다. 컨트롤 그룹(aka. 프로세스 컨테이너)을 통한 자원 관리와 네임스페이슬 통한 자원의 고립 기능을 제공한다. |
| 63 |
</para> |
| 64 |
|
| 65 |
<para> |
| 66 |
<!-- |
| 67 |
The linux containers, <command>lxc</command>, aims to use these |
| 68 |
new functionalities to provide a userspace container object |
| 69 |
which provides full resource isolation and resource control for |
| 70 |
an applications or a system. |
| 71 |
--> |
| 72 |
linux 컨테이너 (<command>lxc</command>)는 사용자영역 컨테이너 개체를 제공하는 새로운 기능을 사용하는 것을 목표로 하고 있다. 이 새로운 기능은 응용 프로그램이나 시스템에서 모든 자원의 격리와 제어를 제공한다. |
| 73 |
</para> |
| 74 |
|
| 75 |
<para> |
| 76 |
<!-- |
| 77 |
The first objective of this project is to make the life easier |
| 78 |
for the kernel developers involved in the containers project and |
| 79 |
especially to continue working on the Checkpoint/Restart new |
| 80 |
features. The <command>lxc</command> is small enough to easily |
| 81 |
manage a container with simple command lines and complete enough |
| 82 |
to be used for other purposes. |
| 83 |
--> |
| 84 |
이 프로젝트의 첫번째 목적은 컨테이너 프로젝트에 속해있는 커널 개발자들의 작업을 편하게 하며, 특히 새로운 기능인 Checkpoint/Restart에 대해 계속 작업을 진행해 나가는 것이다. |
| 85 |
<command>lxc</command>는 작지만, 컨테이너를 간단한 명령어를 통해 쉽게 관리할 수 있고, 다목적으로 사용되기에도 충분하다. |
| 86 |
</para> |
| 87 |
</refsect1> |
| 88 |
|
| 89 |
<refsect1> |
| 90 |
<title><!-- Requirements -->요구사항</title> |
| 91 |
<para> |
| 92 |
<!-- |
| 93 |
The <command>lxc</command> relies on a set of functionalities |
| 94 |
provided by the kernel which needs to be active. Depending of |
| 95 |
the missing functionalities the <command>lxc</command> will |
| 96 |
work with a restricted number of functionalities or will simply |
| 97 |
fail. |
| 98 |
--> |
| 99 |
<command>lxc</command>는 커널이 제공하는 몇가지 기능들에 의존적이며, 해당 기능이 활성화되어 있어야 한다. 부족한 기능에 따라, 제한된 기능만이 동작하거나, 아예 동작을 안 할 수 있다. |
| 100 |
</para> |
| 101 |
|
| 102 |
<para> |
| 103 |
<!-- |
| 104 |
The following list gives the kernel features to be enabled in |
| 105 |
the kernel to have the full features container: |
| 106 |
--> |
| 107 |
아래 리스트는 컨테이너의 모든 기능을 사용하기 위해 활성화되어야 하는 커널 기능들이다. |
| 108 |
</para> |
| 109 |
<programlisting> |
| 110 |
* General setup |
| 111 |
* Control Group support |
| 112 |
-> Namespace cgroup subsystem |
| 113 |
-> Freezer cgroup subsystem |
| 114 |
-> Cpuset support |
| 115 |
-> Simple CPU accounting cgroup subsystem |
| 116 |
-> Resource counters |
| 117 |
-> Memory resource controllers for Control Groups |
| 118 |
* Group CPU scheduler |
| 119 |
-> Basis for grouping tasks (Control Groups) |
| 120 |
* Namespaces support |
| 121 |
-> UTS namespace |
| 122 |
-> IPC namespace |
| 123 |
-> User namespace |
| 124 |
-> Pid namespace |
| 125 |
-> Network namespace |
| 126 |
* Device Drivers |
| 127 |
* Character devices |
| 128 |
-> Support multiple instances of devpts |
| 129 |
* Network device support |
| 130 |
-> MAC-VLAN support |
| 131 |
-> Virtual ethernet pair device |
| 132 |
* Networking |
| 133 |
* Networking options |
| 134 |
-> 802.1d Ethernet Bridging |
| 135 |
* Security options |
| 136 |
-> File POSIX Capabilities |
| 137 |
</programlisting> |
| 138 |
|
| 139 |
<para> |
| 140 |
<!-- |
| 141 |
The kernel version >= 2.6.32 shipped with the distros, will |
| 142 |
work with <command>lxc</command>, this one will have less |
| 143 |
functionalities but enough to be interesting. |
| 144 |
|
| 145 |
The helper script <command>lxc-checkconfig</command> will give |
| 146 |
you information about your kernel configuration. |
| 147 |
--> |
| 148 |
배포판들에 포함된 3.10 이상의 커널에서는 <command>lxc</command>가 동작한다. 매우 작은 기능만 있지만 충분히 사용할 수 있다. |
| 149 |
<command>lxc-checkconfig</command> 스크립트를 사용하면 현재 커널 설정에 대한 정보를 얻을 수 있다. |
| 150 |
</para> |
| 151 |
|
| 152 |
<para> |
| 153 |
<!-- |
| 154 |
The control group can be mounted anywhere, eg: |
| 155 |
<command>mount -t cgroup cgroup /cgroup</command>. |
| 156 |
|
| 157 |
It is however recommended to use cgmanager, cgroup-lite or systemd |
| 158 |
to mount the cgroup hierarchy under /sys/fs/cgroup. |
| 159 |
--> |
| 160 |
컨트롤 그룹은 어디에든지 마운트될 수 있다. 예를 들어 |
| 161 |
<command>mount -t cgroup cgroup /cgroup</command>도 가능하다. |
| 162 |
|
| 163 |
그러나 cgmanager, cgroup-lite 또는 systemd를 사용하여, /sys/fs/cgroup에 cgroup 계층구조를 마운트하는 것이 좋다. |
| 164 |
</para> |
| 165 |
|
| 166 |
</refsect1> |
| 167 |
|
| 168 |
<refsect1> |
| 169 |
<title><!-- Functional specification -->기능 사양</title> |
| 170 |
<para> |
| 171 |
<!-- |
| 172 |
A container is an object isolating some resources of the host, |
| 173 |
for the application or system running in it. |
| 174 |
--> |
| 175 |
컨테이너는 응용프로그램이나 시스템을 내부에서 실행시키기 위해, 호스트의 몇몇 자원들을 격리시키는 객체이다. |
| 176 |
</para> |
| 177 |
<para> |
| 178 |
<!-- |
| 179 |
The application / system will be launched inside a |
| 180 |
container specified by a configuration that is either |
| 181 |
initially created or passed as parameter of the starting |
| 182 |
commands. |
| 183 |
--> |
| 184 |
어플리케이션/시스템은 처음 생성될때 또는 시작 명령어의 인자로 넘겨주었던 설정을 기반으로 한 컨테이너 안에서 실행된다. |
| 185 |
</para> |
| 186 |
|
| 187 |
<para> |
| 188 |
<!-- |
| 189 |
How to run an application in a container ? |
| 190 |
--> |
| 191 |
어떻게 컨테이너 내부에서 응용 프로그램을 실행하는가? |
| 192 |
</para> |
| 193 |
<para> |
| 194 |
<!-- |
| 195 |
Before running an application, you should know what are the |
| 196 |
resources you want to isolate. The default configuration is to |
| 197 |
isolate the pids, the sysv ipc and the mount points. If you want |
| 198 |
to run a simple shell inside a container, a basic configuration |
| 199 |
is needed, especially if you want to share the rootfs. If you |
| 200 |
want to run an application like <command>sshd</command>, you |
| 201 |
should provide a new network stack and a new hostname. If you |
| 202 |
want to avoid conflicts with some files |
| 203 |
eg. <filename>/var/run/httpd.pid</filename>, you should |
| 204 |
remount <filename>/var/run</filename> with an empty |
| 205 |
directory. If you want to avoid the conflicts in all the cases, |
| 206 |
you can specify a rootfs for the container. The rootfs can be a |
| 207 |
directory tree, previously bind mounted with the initial rootfs, |
| 208 |
so you can still use your distro but with your |
| 209 |
own <filename>/etc</filename> and <filename>/home</filename> |
| 210 |
--> |
| 211 |
어플리케이션을 실행하기에 앞서, 고립시키고 싶은 자원을 먼저 알아야 한다. 기본 설정은 pid와 sysv ipc 그리고 마운트 포인트들을 고립시킨다. |
| 212 |
만약에 간단한 쉘을 컨테이너 내부에서 실행시키기 원한다면, 특히 rootfs를 공유하고 싶다면 매우 기초적인 설정이 요구된다. |
| 213 |
<command>sshd</command> 같은 응용 프로그램을 실행시키고 싶다면, 새로운 네트워크 스택과 호스트네임을 제공해 주어야 한다. |
| 214 |
만약 몇몇 파일들, 예를 들어, <filename>/var/run/httpd.pid</filename>이 충돌나는것을 막고 싶다면, <filename>/var/run</filename>를 빈 디렉토리로 다시 마운트하는 것이 필요하다. |
| 215 |
모든 경우의 파일 충돌을 피하고 싶다면, 컨테이너를 위한 루트 파일시스템를 따로 지정해 줄 수도 있다. 루트 파일시스템은 미리 원래의 루트 파일시스템을 바인드 마운트한 디렉토리가 될 수도 있다. 이렇게 되면 자신만의 <filename>/etc</filename>, <filename>/home</filename>을 사용하면서도 배포판을 그대로 사용할 수 있다. |
| 216 |
</para> |
| 217 |
<para> |
| 218 |
<!-- |
| 219 |
Here is an example of directory tree |
| 220 |
for <command>sshd</command>: |
| 221 |
<programlisting> |
| 222 |
[root@lxc sshd]$ tree -d rootfs |
| 223 |
|
| 224 |
rootfs |
| 225 |
|-- bin |
| 226 |
|-- dev |
| 227 |
| |-- pts |
| 228 |
| `-- shm |
| 229 |
| `-- network |
| 230 |
|-- etc |
| 231 |
| `-- ssh |
| 232 |
|-- lib |
| 233 |
|-- proc |
| 234 |
|-- root |
| 235 |
|-- sbin |
| 236 |
|-- sys |
| 237 |
|-- usr |
| 238 |
`-- var |
| 239 |
|-- empty |
| 240 |
| `-- sshd |
| 241 |
|-- lib |
| 242 |
| `-- empty |
| 243 |
| `-- sshd |
| 244 |
`-- run |
| 245 |
`-- sshd |
| 246 |
</programlisting> |
| 247 |
|
| 248 |
and the mount points file associated with it: |
| 249 |
<programlisting> |
| 250 |
[root@lxc sshd]$ cat fstab |
| 251 |
|
| 252 |
/lib /home/root/sshd/rootfs/lib none ro,bind 0 0 |
| 253 |
/bin /home/root/sshd/rootfs/bin none ro,bind 0 0 |
| 254 |
/usr /home/root/sshd/rootfs/usr none ro,bind 0 0 |
| 255 |
/sbin /home/root/sshd/rootfs/sbin none ro,bind 0 0 |
| 256 |
</programlisting> |
| 257 |
--> |
| 258 |
아래는 <command>sshd</command>를 사용하기 위한 디렉토리 트리 예제이다. |
| 259 |
<programlisting> |
| 260 |
[root@lxc sshd]$ tree -d rootfs |
| 261 |
|
| 262 |
rootfs |
| 263 |
|-- bin |
| 264 |
|-- dev |
| 265 |
| |-- pts |
| 266 |
| `-- shm |
| 267 |
| `-- network |
| 268 |
|-- etc |
| 269 |
| `-- ssh |
| 270 |
|-- lib |
| 271 |
|-- proc |
| 272 |
|-- root |
| 273 |
|-- sbin |
| 274 |
|-- sys |
| 275 |
|-- usr |
| 276 |
`-- var |
| 277 |
|-- empty |
| 278 |
| `-- sshd |
| 279 |
|-- lib |
| 280 |
| `-- empty |
| 281 |
| `-- sshd |
| 282 |
`-- run |
| 283 |
`-- sshd |
| 284 |
</programlisting> |
| 285 |
|
| 286 |
그리고, 해당 마운트 포인트 파일의 내용은 아래와 같다. |
| 287 |
<programlisting> |
| 288 |
[root@lxc sshd]$ cat fstab |
| 289 |
|
| 290 |
/lib /home/root/sshd/rootfs/lib none ro,bind 0 0 |
| 291 |
/bin /home/root/sshd/rootfs/bin none ro,bind 0 0 |
| 292 |
/usr /home/root/sshd/rootfs/usr none ro,bind 0 0 |
| 293 |
/sbin /home/root/sshd/rootfs/sbin none ro,bind 0 0 |
| 294 |
</programlisting> |
| 295 |
</para> |
| 296 |
|
| 297 |
<para> |
| 298 |
<!-- |
| 299 |
How to run a system in a container ? |
| 300 |
--> |
| 301 |
어떻게 컨테이너 내에서 시스템을 실행하는가? |
| 302 |
</para> |
| 303 |
|
| 304 |
<para> |
| 305 |
<!-- |
| 306 |
Running a system inside a container is paradoxically easier |
| 307 |
than running an application. Why ? Because you don't have to care |
| 308 |
about the resources to be isolated, everything need to be |
| 309 |
isolated, the other resources are specified as being isolated but |
| 310 |
without configuration because the container will set them |
| 311 |
up. eg. the ipv4 address will be setup by the system container |
| 312 |
init scripts. Here is an example of the mount points file: |
| 313 |
|
| 314 |
<programlisting> |
| 315 |
[root@lxc debian]$ cat fstab |
| 316 |
|
| 317 |
/dev /home/root/debian/rootfs/dev none bind 0 0 |
| 318 |
/dev/pts /home/root/debian/rootfs/dev/pts none bind 0 0 |
| 319 |
</programlisting> |
| 320 |
|
| 321 |
More information can be added to the container to facilitate the |
| 322 |
configuration. For example, make accessible from the container |
| 323 |
the resolv.conf file belonging to the host. |
| 324 |
|
| 325 |
<programlisting> |
| 326 |
/etc/resolv.conf /home/root/debian/rootfs/etc/resolv.conf none bind 0 0 |
| 327 |
</programlisting> |
| 328 |
--> |
| 329 |
컨테이너 내에서 시스템을 실행하는 것은 역설적으로 어플리케이션을 실행하는 것보다 쉽다. 왜 그럴까? 왜냐하면, 어떤 자원이 고립되어야 하는지 고려할 필요가 없다. 모든 자원이 고립되면 된다. 자원들은 별다른 설정없이 고립된다고 지정만 해도 된다. 왜냐하면 컨테이너가 그 자원들을 세팅할 것이기 때문이다. 예를 들어 ipv4 주소는 시스템 컨테이너의 init 스크립트들을 통해 세팅된다. 아래는 마운트 포인트 파일의 예제이다. |
| 330 |
|
| 331 |
<programlisting> |
| 332 |
[root@lxc debian]$ cat fstab |
| 333 |
|
| 334 |
/dev /home/root/debian/rootfs/dev none bind 0 0 |
| 335 |
/dev/pts /home/root/debian/rootfs/dev/pts none bind 0 0 |
| 336 |
</programlisting> |
| 337 |
|
| 338 |
설정을 돕기 위해서 컨테이너에 부가 정보를 추가할 수 있다. 아래와 같이 호스트에 있는 resolv.conf를 컨테이너 안에서 접근할 수 있다. |
| 339 |
|
| 340 |
<programlisting> |
| 341 |
/etc/resolv.conf /home/root/debian/rootfs/etc/resolv.conf none bind 0 0 |
| 342 |
</programlisting> |
| 343 |
</para> |
| 344 |
|
| 345 |
<refsect2> |
| 346 |
<title><!-- Container life cycle -->컨테이너의 생명주기</title> |
| 347 |
<para> |
| 348 |
<!-- |
| 349 |
When the container is created, it contains the configuration |
| 350 |
information. When a process is launched, the container will be |
| 351 |
starting and running. When the last process running inside the |
| 352 |
container exits, the container is stopped. |
| 353 |
--> |
| 354 |
컨테이너가 생성될때, 컨테이너는 설정정보를 포함하게 된다. |
| 355 |
프로세스가 실행될때, 컨테이너는 시작되고 실행된다. |
| 356 |
컨테이너 내에서 실행되던 마지막 프로세스가 종료되면, 컨테이너는 종료된다. |
| 357 |
</para> |
| 358 |
<para> |
| 359 |
<!-- |
| 360 |
In case of failure when the container is initialized, it will |
| 361 |
pass through the aborting state. |
| 362 |
--> |
| 363 |
컨테이너의 초기화가 실패했을 경우, (아래 그림처럼)중단 상태로 바뀌게 된다. |
| 364 |
</para> |
| 365 |
|
| 366 |
<programlisting> |
| 367 |
<![CDATA[ |
| 368 |
--------- |
| 369 |
| STOPPED |<--------------- |
| 370 |
--------- | |
| 371 |
| | |
| 372 |
start | |
| 373 |
| | |
| 374 |
V | |
| 375 |
---------- | |
| 376 |
| STARTING |--error- | |
| 377 |
---------- | | |
| 378 |
| | | |
| 379 |
V V | |
| 380 |
--------- ---------- | |
| 381 |
| RUNNING | | ABORTING | | |
| 382 |
--------- ---------- | |
| 383 |
| | | |
| 384 |
no process | | |
| 385 |
| | | |
| 386 |
V | | |
| 387 |
---------- | | |
| 388 |
| STOPPING |<------- | |
| 389 |
---------- | |
| 390 |
| | |
| 391 |
--------------------- |
| 392 |
]]> |
| 393 |
</programlisting> |
| 394 |
</refsect2> |
| 395 |
|
| 396 |
<refsect2> |
| 397 |
<title><!-- Configuration -->설정</title> |
| 398 |
<para> |
| 399 |
<!-- |
| 400 |
The container is configured through a configuration |
| 401 |
file, the format of the configuration file is described in |
| 402 |
<citerefentry> |
| 403 |
<refentrytitle><filename>lxc.conf</filename></refentrytitle> |
| 404 |
<manvolnum>5</manvolnum> |
| 405 |
</citerefentry> |
| 406 |
--> |
| 407 |
</para> |
| 408 |
컨테이너는 설정파일에 의해서 설정된다. 설정파일의 형식은 다음을 참조하면 된다. |
| 409 |
<citerefentry> |
| 410 |
<refentrytitle><filename>lxc.conf</filename></refentrytitle> |
| 411 |
<manvolnum>5</manvolnum> |
| 412 |
</citerefentry> |
| 413 |
</refsect2> |
| 414 |
|
| 415 |
<refsect2> |
| 416 |
<title><!--Creating / Destroying container |
| 417 |
(persistent container) -->컨테이너의 생성/제거 (지속 컨테이너)</title> |
| 418 |
<para> |
| 419 |
<!-- |
| 420 |
A persistent container object can be |
| 421 |
created via the <command>lxc-create</command> |
| 422 |
command. It takes a container name as parameter and |
| 423 |
optional configuration file and template. |
| 424 |
The name is used by the different |
| 425 |
commands to refer to this |
| 426 |
container. The <command>lxc-destroy</command> command will |
| 427 |
destroy the container object. |
| 428 |
<programlisting> |
| 429 |
lxc-create -n foo |
| 430 |
lxc-destroy -n foo |
| 431 |
</programlisting> |
| 432 |
--> |
| 433 |
지속성 컨테이너 객체는 <command>lxc-create</command> 명령어로 생성된다. 컨테이너이름을 인수로 받으며, 부가적인 설정파일과 템플릿을 지정한다. |
| 434 |
여기서 지정하는 이름은 다른 명령어들을 사용할 때 해당 컨테이너를 참조하기 위해 사용된다. <command>lxc-destroy</command> 명령어는 컨테이너 객체를 제거한다. |
| 435 |
<programlisting> |
| 436 |
lxc-create -n foo |
| 437 |
lxc-destroy -n foo |
| 438 |
</programlisting> |
| 439 |
</para> |
| 440 |
</refsect2> |
| 441 |
|
| 442 |
<refsect2> |
| 443 |
<title><!-- Volatile container -->휘발성 컨테이너</title> |
| 444 |
<para> |
| 445 |
<!-- |
| 446 |
It is not mandatory to create a container object |
| 447 |
before to start it. |
| 448 |
The container can be directly started with a |
| 449 |
configuration file as parameter. |
| 450 |
--> |
| 451 |
컨테이너 시작전에 컨테이너 오브젝트를 생성하는 것이 의무는 아니다. |
| 452 |
컨테이너는 설정파일을 파라미터로 넣어서 바로 시작할 수도 있다. |
| 453 |
</para> |
| 454 |
</refsect2> |
| 455 |
|
| 456 |
<refsect2> |
| 457 |
<title><!-- Starting / Stopping container -->컨테이너의 시작과 종료</title> |
| 458 |
<para> |
| 459 |
<!-- |
| 460 |
When the container has been created, it is ready to run an |
| 461 |
application / system. |
| 462 |
This is the purpose of the <command>lxc-execute</command> and |
| 463 |
<command>lxc-start</command> commands. |
| 464 |
If the container was not created before |
| 465 |
starting the application, the container will use the |
| 466 |
configuration file passed as parameter to the command, |
| 467 |
and if there is no such parameter either, then |
| 468 |
it will use a default isolation. |
| 469 |
If the application is ended, the container will be stopped also, |
| 470 |
but if needed the <command>lxc-stop</command> command can |
| 471 |
be used to kill the still running application. |
| 472 |
--> |
| 473 |
컨테이너가 생성하면 응용 프로그램/시스템이 실행될 준비를 마친 것이다. |
| 474 |
실행하는 것이 바로 <command>lxc-execute</command>와 <command>lxc-start</command> 명령어의 목적이다. |
| 475 |
응용프로그램 시작전에 컨테이너가 생성되어 있지 않다면, 컨테이너는 명령어의 인수로 넘겼던 설정파일을 사용한다. 그런 인수마저 없다면, 기본 고립 환경을 사용한다. |
| 476 |
만약 응용프로그램이 종료되면, 컨테이너도 역시 종료된다. 실행중인 응용프로그램을 종료시키고 싶다면 <command>lxc-stop</command>를 사용하면 된다. |
| 477 |
</para> |
| 478 |
|
| 479 |
<para> |
| 480 |
<!-- |
| 481 |
Running an application inside a container is not exactly the |
| 482 |
same thing as running a system. For this reason, there are two |
| 483 |
different commands to run an application into a container: |
| 484 |
<programlisting> |
| 485 |
lxc-execute -n foo [-f config] /bin/bash |
| 486 |
lxc-start -n foo [-f config] [/bin/bash] |
| 487 |
</programlisting> |
| 488 |
--> |
| 489 |
컨테이너 내부에서 응용프로그램을 실행하는 것은 시스템을 실행하는 것과는 차이가 있다. 이런 이유로 아래의 두가지 명령어가 사용된다. |
| 490 |
<programlisting> |
| 491 |
lxc-execute -n foo [-f config] /bin/bash |
| 492 |
lxc-start -n foo [-f config] [/bin/bash] |
| 493 |
</programlisting> |
| 494 |
</para> |
| 495 |
|
| 496 |
<para> |
| 497 |
<!-- |
| 498 |
<command>lxc-execute</command> command will run the |
| 499 |
specified command into the container via an intermediate |
| 500 |
process, <command>lxc-init</command>. |
| 501 |
This lxc-init after launching the specified command, |
| 502 |
will wait for its end and all other reparented processes. |
| 503 |
(to support daemons in the container). |
| 504 |
In other words, in the |
| 505 |
container, <command>lxc-init</command> has the pid 1 and the |
| 506 |
first process of the application has the pid 2. |
| 507 |
--> |
| 508 |
<command>lxc-execute</command> 명령어는 컨테이너 내부에서 <command>lxc-init</command> 프로세스를 통해 실행할 명령어를 지정할 수 있다. |
| 509 |
lxc-init는 지정한 명령어를 실행한 후, 그 명령어로 실행된 모든 프로세스들이 종료되기를 기다린다. (컨테이너 내부에서 데몬을 지원하기 위해서이다) |
| 510 |
다시 말해서, 컨테이너 내부에서 <command>lxc-init</command>는 1번 pid를 갖고, 응용프로그램의 첫번째 프로세스는 2번 pid를 가진다. |
| 511 |
</para> |
| 512 |
|
| 513 |
<para> |
| 514 |
<!-- |
| 515 |
<command>lxc-start</command> command will run directly the specified |
| 516 |
command into the container. |
| 517 |
The pid of the first process is 1. If no command is |
| 518 |
specified <command>lxc-start</command> will |
| 519 |
run the command defined in lxc.init.cmd or if not set, |
| 520 |
<filename>/sbin/init</filename> . |
| 521 |
--> |
| 522 |
<command>lxc-start</command> 명령어는 지정한 명령어를 컨테이너 내에서 직접 실행한다. 첫 프로세스의 pid는 1번이다. 만약 어떤 명령어도 지정되지 않으면, lxc.init.cmd에 지정된 명령어를 실행한다. 이마저도 지정되있지 않으면, <filename>/sbin/init</filename>를 실행한다. |
| 523 |
</para> |
| 524 |
|
| 525 |
<para> |
| 526 |
<!-- |
| 527 |
To summarize, <command>lxc-execute</command> is for running |
| 528 |
an application and <command>lxc-start</command> is better suited for |
| 529 |
running a system. |
| 530 |
--> |
| 531 |
요약하자면, <command>lxc-execute</command>는 응용 프로그램 실행을 위해서, <command>lxc-start</command>는 시스템 실행을 위해 적합하다. |
| 532 |
</para> |
| 533 |
|
| 534 |
<para> |
| 535 |
<!-- |
| 536 |
If the application is no longer responding, is inaccessible or is |
| 537 |
not able to finish by itself, a |
| 538 |
wild <command>lxc-stop</command> command will kill all the |
| 539 |
processes in the container without pity. |
| 540 |
<programlisting> |
| 541 |
lxc-stop -n foo |
| 542 |
</programlisting> |
| 543 |
--> |
| 544 |
만약 어플리케이션이 더이상 응답하지 않거나, 접근이 불가능하거나, 스스로 종료되지 못할 경우, <command>lxc-stop</command> 명령어는 컨테이너 내의 모든 프로세스들을 가차없이 종료시킬 것이다. |
| 545 |
<programlisting> |
| 546 |
lxc-stop -n foo |
| 547 |
</programlisting> |
| 548 |
</para> |
| 549 |
</refsect2> |
| 550 |
|
| 551 |
<refsect2> |
| 552 |
<title><!-- Connect to an available tty -->사용가능한 tty 접속</title> |
| 553 |
<para> |
| 554 |
<!-- |
| 555 |
If the container is configured with the ttys, it is possible |
| 556 |
to access it through them. It is up to the container to |
| 557 |
provide a set of available tty to be used by the following |
| 558 |
command. When the tty is lost, it is possible to reconnect it |
| 559 |
without login again. |
| 560 |
<programlisting> |
| 561 |
lxc-console -n foo -t 3 |
| 562 |
</programlisting> |
| 563 |
--> |
| 564 |
컨테이너에 tty가 설정되어 있다면, tty를 통해 컨테이너에 접근할 수 있다. |
| 565 |
아래 명령어를 통해 사용될 가능한 tty를 제공하는 것은 컨테이너에 달려있다. |
| 566 |
tty가 종료되었을 때는 다시 로그인하지 않고도 재접속할 수 있다. |
| 567 |
<programlisting> |
| 568 |
lxc-console -n foo -t 3 |
| 569 |
</programlisting> |
| 570 |
</para> |
| 571 |
</refsect2> |
| 572 |
|
| 573 |
<refsect2> |
| 574 |
<title><!-- Freeze / Unfreeze container -->컨테이너 동결/동결 해제</title> |
| 575 |
<para> |
| 576 |
<!-- |
| 577 |
Sometime, it is useful to stop all the processes belonging to |
| 578 |
a container, eg. for job scheduling. The commands: |
| 579 |
<programlisting> |
| 580 |
lxc-freeze -n foo |
| 581 |
</programlisting> |
| 582 |
|
| 583 |
will put all the processes in an uninteruptible state and |
| 584 |
|
| 585 |
<programlisting> |
| 586 |
lxc-unfreeze -n foo |
| 587 |
</programlisting> |
| 588 |
|
| 589 |
will resume them. |
| 590 |
--> |
| 591 |
스케줄링 등을 위해 컨테이너에 속해있는 모든 프로세스를 정지 시키는 것은 때로 유용할 수 있다. 아래 명령어들을 사용하면 된다. |
| 592 |
|
| 593 |
<programlisting> |
| 594 |
lxc-freeze -n foo |
| 595 |
</programlisting> |
| 596 |
는 모든 프로세스들을 인터럽트 불가능한 상태로 만든다. |
| 597 |
|
| 598 |
<programlisting> |
| 599 |
lxc-unfreeze -n foo |
| 600 |
</programlisting> |
| 601 |
는 모든 프로세스를 정지 해제 시킨다. |
| 602 |
</para> |
| 603 |
|
| 604 |
<para> |
| 605 |
<!-- |
| 606 |
This feature is enabled if the cgroup freezer is enabled in the |
| 607 |
kernel. |
| 608 |
--> |
| 609 |
이 기능은 커널에서 cgroup freezer 기능이 활성화 되어 있어야 사용 가능하다. |
| 610 |
</para> |
| 611 |
</refsect2> |
| 612 |
|
| 613 |
<refsect2> |
| 614 |
<title><!-- Getting information about container --> |
| 615 |
컨테이너 관련 정보 얻어오기</title> |
| 616 |
<para> |
| 617 |
<!-- |
| 618 |
When there are a lot of containers, it is hard to follow |
| 619 |
what has been created or destroyed, what is running or what are |
| 620 |
the pids running into a specific container. For this reason, the |
| 621 |
following commands may be useful: |
| 622 |
<programlisting> |
| 623 |
lxc-ls |
| 624 |
lxc-info -n foo |
| 625 |
</programlisting> |
| 626 |
--> |
| 627 |
컨테이너가 많이 존재하는 경우, 어떤 것이 생성되고 제거됬는지, 어떤 것이 실행 중인지 또는 어떤 프로세스들이 특정 컨테이너 내에서 실행되는지를 따라가기 힘들다. 이를 위해 다음과 같은 명령어들이 유용하게 사용될 수 있다. |
| 628 |
<programlisting> |
| 629 |
lxc-ls |
| 630 |
lxc-info -n foo |
| 631 |
</programlisting> |
| 632 |
</para> |
| 633 |
<para> |
| 634 |
<!-- |
| 635 |
<command>lxc-ls</command> lists the containers of the |
| 636 |
system. |
| 637 |
--> |
| 638 |
<command>lxc-ls</command>는 시스템의 컨테이너들의 리스트를 표시한다. |
| 639 |
</para> |
| 640 |
|
| 641 |
<para> |
| 642 |
<!-- |
| 643 |
<command>lxc-info</command> gives information for a specific |
| 644 |
container. |
| 645 |
--> |
| 646 |
<command>lxc-info</command>는 지정한 컨테이너의 정보를 얻어온다. |
| 647 |
</para> |
| 648 |
|
| 649 |
<para> |
| 650 |
<!-- |
| 651 |
Here is an example on how the combination of these commands |
| 652 |
allows one to list all the containers and retrieve their state. |
| 653 |
<programlisting> |
| 654 |
for i in $(lxc-ls -1); do |
| 655 |
lxc-info -n $i |
| 656 |
done |
| 657 |
</programlisting> |
| 658 |
--> |
| 659 |
아래는 명령어들을 조합하여 컨테이너들의 리스트를 얻어오고 상태를 출력하는 예제이다. |
| 660 |
<programlisting> |
| 661 |
for i in $(lxc-ls -1); do |
| 662 |
lxc-info -n $i |
| 663 |
done |
| 664 |
</programlisting> |
| 665 |
</para> |
| 666 |
|
| 667 |
</refsect2> |
| 668 |
|
| 669 |
<refsect2> |
| 670 |
<title><!-- Monitoring container -->컨테이너 모니터링</title> |
| 671 |
<para> |
| 672 |
<!-- |
| 673 |
It is sometime useful to track the states of a container, |
| 674 |
for example to monitor it or just to wait for a specific |
| 675 |
state in a script. |
| 676 |
--> |
| 677 |
컨테이너의 상태를 추적하는 것은 때때로 매우 유용하다. |
| 678 |
예를 들어, 상태를 모니터링하거나, 스크립트에서 특정상태를 기다리는 경우이다. |
| 679 |
</para> |
| 680 |
|
| 681 |
<para> |
| 682 |
<!-- |
| 683 |
<command>lxc-monitor</command> command will monitor one or |
| 684 |
several containers. The parameter of this command accept a |
| 685 |
regular expression for example: |
| 686 |
<programlisting> |
| 687 |
lxc-monitor -n "foo|bar" |
| 688 |
</programlisting> |
| 689 |
will monitor the states of containers named 'foo' and 'bar', and: |
| 690 |
<programlisting> |
| 691 |
lxc-monitor -n ".*" |
| 692 |
</programlisting> |
| 693 |
will monitor all the containers. |
| 694 |
--> |
| 695 |
<command>lxc-monitor</command> 명령어는 하나 또는 여러개의 컨테이너들을 모니터링한다. 이 명령어의 인수로 정규표현식을 넘길 수도 있다. |
| 696 |
예를 들면, |
| 697 |
<programlisting> |
| 698 |
lxc-monitor -n "foo|bar" |
| 699 |
</programlisting> |
| 700 |
는 'foo'와 'bar'라는 이름의 컨테이너의 상태 변화를 모니터링한다. 그리고, |
| 701 |
<programlisting> |
| 702 |
lxc-monitor -n ".*" |
| 703 |
</programlisting> |
| 704 |
는 모든 컨테이너를 모니터링한다. |
| 705 |
</para> |
| 706 |
<para> |
| 707 |
<!-- |
| 708 |
For a container 'foo' starting, doing some work and exiting, |
| 709 |
the output will be in the form: |
| 710 |
<programlisting> |
| 711 |
'foo' changed state to [STARTING] |
| 712 |
'foo' changed state to [RUNNING] |
| 713 |
'foo' changed state to [STOPPING] |
| 714 |
'foo' changed state to [STOPPED] |
| 715 |
</programlisting> |
| 716 |
--> |
| 717 |
'foo' 컨테이너가 시작되고 몇 가지 작업을 수행하고 종료된 경우, |
| 718 |
출력은 다음과 같다. |
| 719 |
<programlisting> |
| 720 |
'foo' changed state to [STARTING] |
| 721 |
'foo' changed state to [RUNNING] |
| 722 |
'foo' changed state to [STOPPING] |
| 723 |
'foo' changed state to [STOPPED] |
| 724 |
</programlisting> |
| 725 |
</para> |
| 726 |
<para> |
| 727 |
<!-- |
| 728 |
<command>lxc-wait</command> command will wait for a specific |
| 729 |
state change and exit. This is useful for scripting to |
| 730 |
synchronize the launch of a container or the end. The |
| 731 |
parameter is an ORed combination of different states. The |
| 732 |
following example shows how to wait for a container if they went |
| 733 |
to the background. |
| 734 |
|
| 735 |
<programlisting> |
| 736 |
<![CDATA[ |
| 737 |
# launch lxc-wait in background |
| 738 |
lxc-wait -n foo -s STOPPED & |
| 739 |
LXC_WAIT_PID=$! |
| 740 |
|
| 741 |
# this command goes in background |
| 742 |
lxc-execute -n foo mydaemon & |
| 743 |
|
| 744 |
# block until the lxc-wait exits |
| 745 |
# and lxc-wait exits when the container |
| 746 |
# is STOPPED |
| 747 |
wait $LXC_WAIT_PID |
| 748 |
echo "'foo' is finished" |
| 749 |
]]> |
| 750 |
</programlisting> |
| 751 |
--> |
| 752 |
<command>lxc-wait</command> 명령어는 지정한 상태로 변화되는 것을 기다린다. 이 명령어는 컨테이너의 시작이나 종료와 동기화되는 스크립트를 작성할 때 유용하다. |
| 753 |
인수는 다른 상태들을 OR로 묶어서 지정해 줄 수 있다. 아래 예제는 백그라운드에서 어떻게 컨테이너의 상태 변화를 기다리는지 보여준다. |
| 754 |
<programlisting> |
| 755 |
<![CDATA[ |
| 756 |
# launch lxc-wait in background |
| 757 |
lxc-wait -n foo -s STOPPED & |
| 758 |
LXC_WAIT_PID=$! |
| 759 |
|
| 760 |
# this command goes in background |
| 761 |
lxc-execute -n foo mydaemon & |
| 762 |
|
| 763 |
# block until the lxc-wait exits |
| 764 |
# and lxc-wait exits when the container |
| 765 |
# is STOPPED |
| 766 |
wait $LXC_WAIT_PID |
| 767 |
echo "'foo' is finished" |
| 768 |
]]> |
| 769 |
</programlisting> |
| 770 |
</para> |
| 771 |
</refsect2> |
| 772 |
|
| 773 |
<refsect2> |
| 774 |
<title><!-- Setting the control group for container --> |
| 775 |
컨테이너 컨트롤 그룹 설정 |
| 776 |
</title> |
| 777 |
<para> |
| 778 |
<!-- |
| 779 |
The container is tied with the control groups, when a |
| 780 |
container is started a control group is created and associated |
| 781 |
with it. The control group properties can be read and modified |
| 782 |
when the container is running by using the lxc-cgroup command. |
| 783 |
--> |
| 784 |
컨테이너는 컨트롤 그룹과 결합되어 있다. |
| 785 |
컨테이너가 시작되면 컨트롤그룹이 만들어지고 해당 컨트롤 그룹과 연결된다. |
| 786 |
컨테이너가 실행중일 때, lxc-cgroup 명령어를 이용해 컨트롤 그룹 속성은 읽거나 수정될 수 있다. |
| 787 |
</para> |
| 788 |
<para> |
| 789 |
<!-- |
| 790 |
<command>lxc-cgroup</command> command is used to set or get a |
| 791 |
control group subsystem which is associated with a |
| 792 |
container. The subsystem name is handled by the user, the |
| 793 |
command won't do any syntax checking on the subsystem name, if |
| 794 |
the subsystem name does not exists, the command will fail. |
| 795 |
--> |
| 796 |
<command>lxc-cgroup</command> 명령어는 컨테이너와 연결된 컨트롤 그룹 서브시스템의 값을 얻어오거나 설정한다. |
| 797 |
서브시스템의 이름은 사용자가 결정하며, 이 명령어는 이름이 적합한지 여부를 검사하지 않는다. |
| 798 |
만약 서브시스템의 이름이 없다면 명령어는 실패할 것이다. |
| 799 |
</para> |
| 800 |
<para> |
| 801 |
<!-- |
| 802 |
<programlisting> |
| 803 |
lxc-cgroup -n foo cpuset.cpus |
| 804 |
</programlisting> |
| 805 |
will display the content of this subsystem. |
| 806 |
<programlisting> |
| 807 |
lxc-cgroup -n foo cpu.shares 512 |
| 808 |
</programlisting> |
| 809 |
will set the subsystem to the specified value. |
| 810 |
--> |
| 811 |
<programlisting> |
| 812 |
lxc-cgroup -n foo cpuset.cpus |
| 813 |
</programlisting> |
| 814 |
는 해당 서브시스템의 내용을 표시한다. |
| 815 |
<programlisting> |
| 816 |
lxc-cgroup -n foo cpu.shares 512 |
| 817 |
</programlisting> |
| 818 |
는 해당 서브시스템의 값을 설정한다. |
| 819 |
</para> |
| 820 |
</refsect2> |
| 821 |
</refsect1> |
| 822 |
|
| 823 |
<refsect1> |
| 824 |
<title><!-- Bugs -->버그</title> |
| 825 |
<para> |
| 826 |
<!-- |
| 827 |
The <command>lxc</command> is still in development, so the |
| 828 |
command syntax and the API can change. The version 1.0.0 will be |
| 829 |
the frozen version. |
| 830 |
--> |
| 831 |
<command>lxc</command>는 아직 개발중이다. 그래서 명령어 사용법이나, API가 변경될 수 있다. 버전 1.0.0은 변경되지 않는 고정된 버전이다. |
| 832 |
</para> |
| 833 |
</refsect1> |
| 834 |
|
| 835 |
&seealso; |
| 836 |
|
| 837 |
</refentry> |
| 838 |
|
| 839 |
<!-- Keep this comment at the end of the file Local variables: mode: |
| 840 |
sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil |
| 841 |
sgml-always-quote-attributes:t sgml-indent-step:2 sgml-indent-data:t |
| 842 |
sgml-parent-document:nil sgml-default-dtd-file:nil |
| 843 |
sgml-exposed-tags:nil sgml-local-catalogs:nil |
| 844 |
sgml-local-ecat-files:nil End: --> |