173
173
<title>Functional specification</title>
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.
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.
181
184
<para>How to run an application in a container ?</para>
328
<title>Creating / Destroying the containers</title>
324
<title>Creating / Destroying container
325
(persistent container)</title>
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.
344
<title>Starting / Stopping a container</title>
343
<title>Volatile container</title>
344
<para>It is not mandatory to create a container object
346
The container can be directly started with a
347
configuration file as parameter.
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.
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:
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>
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.
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>.
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.
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.