lxc.rst
changeset 2317 897bb1696e5f
parent 2316 7de68fce3e7d
child 2345 cb168a3d27ec
equal deleted inserted replaced
2316:7de68fce3e7d 2317:897bb1696e5f
     3 =====
     3 =====
     4  LXC
     4  LXC
     5 =====
     5 =====
     6 .. contents::
     6 .. contents::
     7    :local:
     7    :local:
       
     8 
       
     9 LXC releases
       
    10 ============
       
    11 
       
    12 https://discuss.linuxcontainers.org/tags/release
       
    13   Announces of LXC & LXD releases.
       
    14 https://discuss.linuxcontainers.org/t/lxc-3-0-0-has-been-released/1449
       
    15   LXC 3.0.0 has been released.
       
    16 
       
    17 Supported templates
       
    18 ===================
       
    19 
       
    20 https://github.com/lxc/lxc-templates
       
    21   Old style template scripts for LXC (prefer distrobuilder).
       
    22 https://github.com/lxc/distrobuilder
       
    23   System container image builder for LXC and LXD.
       
    24 https://brauner.github.io/2018/02/27/lxc-removes-legacy-template-build-system.html
       
    25   Details about replacing template stripts.
     8 
    26 
     9 Install LXC under Debian
    27 Install LXC under Debian
    10 ========================
    28 ========================
    11 ::
    29 ::
    12 
    30 
    39   $ sudo service lxc-net start
    57   $ sudo service lxc-net start
    40 
    58 
    41 Create new container in LXC
    59 Create new container in LXC
    42 ===========================
    60 ===========================
    43 
    61 
    44 ``-t`` defines distro name, ``-n`` gives name for container for further
    62 Create container from template::
    45 referencing, ``--`` allow pass options to template script, ``-r`` specifies
       
    46 Debian release::
       
    47 
    63 
    48   $ sudo lxc-create -t debian -n debtest -- -r sid
    64   $ sudo lxc-create -t $TMPL -n $NAME -- $EXTRA_ARGS
    49 
    65 
    50 In order to use another miror::
    66 .. note::
       
    67    * ``-t`` defines distro name
       
    68    * ``-n`` gives name for container for further referencing
       
    69    * everything after ``--`` is passed to template script
    51 
    70 
    52   $ MIRROR=http://httpredir.debian.org/debian sudo lxc-create -t debian -n debtest -- -r sid
    71 Template name is based on file name from ``/usr/share/lxc/templates`` directory without ``lxc-``
       
    72 prefix.
    53 
    73 
    54 Getting help for template specific options::
    74 List available templates with::
       
    75 
       
    76   $ ls -alh /usr/share/lxc/templates/
       
    77 
       
    78 Examples of container creation command::
       
    79 
       
    80   $ sudo lxc-create -t debian -n deb-sid --  -r sid --enable-non-free
       
    81   $ sudo lxc-create -t debian -n deb-testing --  -r testing
       
    82   $ sudo lxc-create -t debian -n deb-stable --  -r stable -a amd64
       
    83 
       
    84   $ sudo lxc-create -t alpine -n alpine-3.7 --  -r 3.7
       
    85 
       
    86 Each template has own options, which can be passed after ``--``. To get help on template specific
       
    87 options run::
    55 
    88 
    56   $ /usr/share/lxc/templates/lxc-ubuntu -h
    89   $ /usr/share/lxc/templates/lxc-ubuntu -h
    57   $ /usr/share/lxc/templates/lxc-debian -h
    90   $ /usr/share/lxc/templates/lxc-debian -h
    58   $ /usr/share/lxc/templates/lxc-alpine -h
    91   $ /usr/share/lxc/templates/lxc-alpine -h
    59   ...
    92   ...
       
    93 
       
    94 For Debian in order to use another miror::
       
    95 
       
    96   $ MIRROR=http://httpredir.debian.org/debian sudo lxc-create -t debian -n debtest -- -r sid
       
    97 
       
    98 Since LXC v3.0 sh-templates moved to separate project and only 4 are left supported::
       
    99 
       
   100   $ lxc-create my-busybox -t busybox
       
   101   $ lxc-create my-x -t download
       
   102   $ lxc-create c1 -t local -- --metadata /path/to/meta.tar.xz --fstree /path/to/rootfs.tar.xz
       
   103   $ lxc-create c2 -t oci -- --url docker://alpine
    60 
   104 
    61 Put ``veth`` network configuration into container config ``/var/lib/lxc/$NAME/config``::
   105 Put ``veth`` network configuration into container config ``/var/lib/lxc/$NAME/config``::
    62 
   106 
    63   lxc.network.type = veth
   107   lxc.network.type = veth
    64   lxc.network.flags = up
   108   lxc.network.flags = up