github.com/ratanraj/packer@v1.3.2/website/source/docs/builders/lxc.html.md (about)

     1  ---
     2  description: |
     3      The `lxc` Packer builder builds containers for lxc1. The builder starts an LXC
     4      container, runs provisioners within this container, then exports the container
     5      as a tar.gz of the root file system.
     6  layout: docs
     7  page_title: 'LXC - Builders'
     8  sidebar_current: 'docs-builders-lxc`'
     9  ...
    10  
    11  # LXC Builder
    12  
    13  Type: `lxc`
    14  
    15  The `lxc` Packer builder builds containers for lxc1. The builder starts an LXC
    16  container, runs provisioners within this container, then exports the container
    17  as a tar.gz of the root file system.
    18  
    19  The LXC builder requires a modern linux kernel and the `lxc` or `lxc1` package.
    20  This builder does not work with LXD.
    21  
    22  ~> Note: to build Centos images on a Debian family host, you will need the `yum`
    23  package installed.
    24  <br>Some provisioners such as `ansible-local` get confused when running in
    25  a container of a different family. E.G. it will attempt to use `apt-get` to
    26  install packages, when running in a Centos container if the parent OS is Debian
    27  based.
    28  
    29  ## Basic Example
    30  
    31  Below is a fully functioning example.
    32  
    33  ``` {.javascript}
    34  {
    35    "builders": [
    36      {
    37        "type": "lxc",
    38        "name": "lxc-trusty",
    39        "config_file": "/tmp/lxc/config",
    40        "template_name": "ubuntu",
    41        "template_environment_vars": [
    42          "SUITE=trusty"
    43        ]
    44      },
    45      {
    46        "type": "lxc",
    47        "name": "lxc-xenial",
    48        "config_file": "/tmp/lxc/config",
    49        "template_name": "ubuntu",
    50        "template_environment_vars": [
    51          "SUITE=xenial"
    52        ]
    53      },
    54      {
    55        "type": "lxc",
    56        "name": "lxc-jessie",
    57        "config_file": "/tmp/lxc/config",
    58        "template_name": "debian",
    59        "template_environment_vars": [
    60          "SUITE=jessie"
    61        ]
    62      },
    63      {
    64        "type": "lxc",
    65        "name": "lxc-centos-7-x64",
    66        "config_file": "/tmp/lxc/config",
    67        "template_name": "centos",
    68        "template_parameters": [
    69          "-R","7",
    70          "-a","x86_64"
    71         ]
    72      }
    73    ]
    74  }
    75  ```
    76  
    77  ## Configuration Reference
    78  
    79  ### Required:
    80  
    81  -  `config_file` (string) - The path to the lxc configuration file.
    82  
    83  -  `template_name` (string) - The LXC template name to use.
    84  
    85  -  `template_environment_vars` (array of strings) - Environmental variables to
    86     use to build the template with.
    87  
    88  ### Optional:
    89  
    90  -  `target_runlevel` (number) - The minimum run level to wait for the container to
    91     reach. Note some distributions (Ubuntu) simulate run levels and may report
    92     5 rather than 3.
    93  
    94  -  `output_directory` (string) - The directory in which to save the exported
    95     tar.gz. Defaults to `output-<BuildName>` in the current directory.
    96  
    97  -  `container_name` (string) - The name of the LXC container. Usually stored in
    98     `/var/lib/lxc/containers/<container_name>`. Defaults to
    99     `packer-<BuildName>`.
   100  
   101  -  `command_wrapper` (string) - Allows you to specify a wrapper command, such
   102     as `ssh` so you can execute packer builds on a remote host. Defaults to
   103     Empty.
   104  
   105  -  `init_timeout` (string) - The timeout in seconds to wait for the the
   106     container to start. Defaults to 20 seconds.
   107  
   108  -  `template_parameters` (array of strings) - Options to pass to the given
   109     `lxc-template` command, usually located in
   110     `/usr/share/lxc/templates/lxc-<template_name>`. Note: This gets passed as
   111     ARGV to the template command. Ensure you have an array of strings, as
   112     a single string with spaces probably won't work. Defaults to `[]`.
   113  
   114  -  `create_options` (array of strings) - Options to pass to `lxc-create`. For
   115     instance, you can specify a custom LXC container configuration file with
   116     `["-f", "/path/to/lxc.conf"]`. Defaults to `[]`. See `man 1 lxc-create` for
   117     available options.
   118  
   119  -  `start_options` (array of strings) - Options to pass to `lxc-start`. For
   120     instance, you can override parameters from the LXC container configuration
   121     file via `["--define", "KEY=VALUE"]`. Defaults to `[]`. See `man 1
   122     lxc-start` for available options.
   123  
   124  -  `attach_options` (array of strings) - Options to pass to `lxc-attach`. For
   125     instance, you can prevent the container from inheriting the host machine's
   126     environment by specifying `["--clear-env"]`. Defaults to `[]`. See `man 1
   127     lxc-attach` for available options.