~ubuntu-branches/ubuntu/quantal/lxc/quantal-201206191543

« back to all changes in this revision

Viewing changes to doc/lxc.sgml.in

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter
  • Date: 2010-06-28 10:15:48 UTC
  • mfrom: (1.2.4 upstream)
  • mto: (3.1.15 sid)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20100628101548-lmqvw55ypaxtbhhh
Tags: upstream-0.7.1
ImportĀ upstreamĀ versionĀ 0.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
  <refsect1>
93
93
    <title>Requirements</title>
94
94
    <para>
95
 
      The <command>lxc</command> relies on a set of functionalies
 
95
      The <command>lxc</command> relies on a set of functionalities
96
96
      provided by the kernel which needs to be active. Depending of
97
97
      the missing functionalities the <command>lxc</command> will
98
98
      work with a restricted number of functionalities or will simply
172
172
  <refsect1>
173
173
    <title>Functional specification</title>
174
174
    <para>
175
 
      A container is an object where the configuration is
176
 
      persistent. The application will be launched inside this
177
 
      container and it will use the configuration which was previously
178
 
      created or specified in parameter of the command.
 
175
      A container is an object isolating some resources of the host,
 
176
      for the application or system running in it.
 
177
    </para>
 
178
    <para>
 
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 commands.
179
182
    </para>
180
183
 
181
184
    <para>How to run an application in a container ?</para>
307
310
    </refsect2>
308
311
 
309
312
    <refsect2>
310
 
      <title>Volatile containers</title>
311
 
      <para>The container can be directly started with a
312
 
        configuration file in parameter without creating them before.
313
 
      </para>
314
 
    </refsect2>
315
 
 
316
 
    <refsect2>
317
313
      <title>Configuration</title>
318
314
      <para>The container is configured through a configuration
319
315
      file, the format of the configuration file is described in 
325
321
    </refsect2>
326
322
 
327
323
    <refsect2>
328
 
      <title>Creating / Destroying the containers</title>
 
324
      <title>Creating / Destroying container
 
325
        (persistent container)</title>
329
326
      <para>
330
 
        The container is created via the <command>lxc-create</command>
331
 
        command. It takes a container name as parameter and an
332
 
        optional configuration file. The name is used by the different
 
327
        A persistent container object can be
 
328
        created via the <command>lxc-create</command>
 
329
        command. It takes a container name as parameter and
 
330
        optional configuration file and template.
 
331
        The name is used by the different
333
332
        commands to refer to this
334
333
        container. The <command>lxc-destroy</command> command will
335
334
        destroy the container object.
341
340
    </refsect2>
342
341
 
343
342
    <refsect2>
344
 
      <title>Starting / Stopping a container</title>
 
343
        <title>Volatile container</title>
 
344
        <para>It is not mandatory to create a container object
 
345
        before to start it.
 
346
        The container can be directly started with a
 
347
        configuration file as parameter.
 
348
        </para>
 
349
    </refsect2>
 
350
 
 
351
    <refsect2>
 
352
      <title>Starting / Stopping container</title>
345
353
      <para>When the container has been created, it is ready to run an
346
 
      application / system. When the application has to be destroyed,
347
 
      the container can be stopped, that will kill all the processes
348
 
      of the container. If the container was not created before
 
354
      application / system.
 
355
      This is the purpose of the <command>lxc-execute</command> and
 
356
      <command>lxc-start</command> commands.
 
357
      If the container was not created before
349
358
      starting the application, the container will use the
350
 
      configuration file passed as parameter to the command, otherwise
351
 
      it will use the default isolation.</para>
 
359
      configuration file passed as parameter to the command,
 
360
      and if there is no such parameter either, then
 
361
      it will use a default isolation.
 
362
      If the application is ended, the container will be stopped also,
 
363
      but if needed the <command>lxc-stop</command> command can
 
364
      be used to kill the still running application.
 
365
      </para>
352
366
      
353
367
      <para>
354
368
        Running an application inside a container is not exactly the
355
 
        same thing as running a system. For this reason, there is two
356
 
        commands to run an application into a container:
 
369
        same thing as running a system. For this reason, there are two
 
370
        different commands to run an application into a container:
357
371
        <programlisting>
358
372
          lxc-execute -n foo [-f config] /bin/bash
359
 
          lxc-start -n foo [/bin/bash]
 
373
          lxc-start -n foo [-f config] [/bin/bash]
360
374
        </programlisting>
361
375
      </para>
362
376
 
363
377
      <para>
364
378
        <command>lxc-execute</command> command will run the
365
 
        specified command into a container but it will mount /proc
366
 
        and autocreate/autodestroy the container if it does not
367
 
        exist. It will furthermore create an intermediate
368
 
        process, <command>lxc-init</command>, which is in charge to
369
 
        launch the specified command, that allows to support daemons
370
 
        in the container. In other words, in the
371
 
        container <command>lxc-init</command> has the pid 1 and the
 
379
        specified command into the container via an intermediate
 
380
        process, <command>lxc-init</command>.
 
381
        This lxc-init after launching  the specified command,
 
382
        will wait for its end and all other reparented processes.
 
383
        (that allows to support daemons in the container).
 
384
        In other words, in the
 
385
        container, <command>lxc-init</command> has the pid 1 and the
372
386
        first process of the application has the pid 2.
373
387
      </para>
374
388
 
375
389
      <para>
376
 
        <command>lxc-start</command> command will run the specified
377
 
        command into the container doing nothing else than using the
378
 
        configuration specified by <command>lxc-create</command>.
 
390
        <command>lxc-start</command> command will run directly the specified
 
391
        command into the container.
379
392
        The pid of the first process is 1. If no command is
380
393
        specified <command>lxc-start</command> will
381
394
        run <filename>/sbin/init</filename>.
383
396
 
384
397
      <para>
385
398
        To summarize, <command>lxc-execute</command> is for running
386
 
        an application and <command>lxc-start</command> is for
 
399
        an application and <command>lxc-start</command> is better suited for
387
400
        running a system.
388
401
      </para>
389
402
 
390
403
      <para>
391
 
        If the application is no longer responding, inaccessible or is
 
404
        If the application is no longer responding, is inaccessible or is
392
405
        not able to finish by itself, a
393
406
        wild <command>lxc-stop</command> command will kill all the
394
407
        processes in the container without pity.
413
426
    </refsect2>
414
427
 
415
428
    <refsect2>
416
 
      <title>Freeze / Unfreeze a container</title>
 
429
      <title>Freeze / Unfreeze container</title>
417
430
      <para>
418
431
        Sometime, it is useful to stop all the processes belonging to
419
432
        a container, eg. for job scheduling. The commands:
427
440
          lxc-unfreeze -n foo
428
441
        </programlisting>
429
442
 
430
 
        will resume all the tasks.
 
443
        will resume them.
431
444
      </para>
432
445
 
433
446
      <para>
437
450
    </refsect2>
438
451
 
439
452
    <refsect2>
440
 
      <title>Getting information about the container</title>
 
453
      <title>Getting information about container</title>
441
454
      <para>When there are a lot of containers, it is hard to follow
442
455
      what has been created or destroyed, what is running or what are
443
456
      the pids running into a specific container. For this reason, the
444
 
      following commands give this information:
 
457
      following commands may be usefull:
445
458
        <programlisting>
446
459
          lxc-ls
447
460
          lxc-ps --name foo
519
532
    </refsect2>
520
533
 
521
534
    <refsect2>
522
 
      <title>Monitoring the containers</title>
 
535
      <title>Monitoring container</title>
523
536
      <para>It is sometime useful to track the states of a container,
524
537
      for example to monitor it or just to wait for a specific
525
538
      state in a script.
576
589
    </refsect2>
577
590
 
578
591
    <refsect2>
579
 
      <title>Setting the control group for a container</title>
 
592
      <title>Setting the control group for container</title>
580
593
      <para>The container is tied with the control groups, when a
581
594
        container is started a control group is created and associated
582
595
        with it. The control group properties can be read and modified