7.2.2. Using Customized EZ Templates

You can create custom OS and application templates tailored to your needs. In such a template, you only need to specify parameters that differ from those in the default template. All other parameters—that are not explicitly set in the custom template—are inherited from the corresponding default template.

To create a custom template, do the following:

  1. If required, install the default OS template on the hardware node. For example:

    yum install centos-7-x86_64-ez
  2. Create a directory for your template at the location where the default template directory is. For example, for a custom CentOS 7 64-bit template mytmpl, create the directory /vz/template/centos/7/x86_64/config/os/mytmpl.
  3. If you are creating a custom OS template, specify repositories. For example, copy the file mirrorlist from the default template directory to your template directory:

    # cp /vz/template/centos/7/x86_64/config/os/default/mirrorlist \
    /vz/template/centos/7/x86_64/config/os/mytmpl
  4. In your template directory, create the file packages listing the RPMs you need, one per line. For example,

    systemd
    yum

    Note

    Note: The minimal list of packages to include in a custom template may vary depending on guest OS. For example, CentOS 7 templates require that systemd be specified in the packages file for the prlctl enter command to work on resulting containers.

  5. Optionally, change more template parameters according to your needs (for a description of parameters, see the next section).

Your custom template is ready. In this example, it is an OS template that contains systemd, yum, and all their prerequisites. You now can create containers based on it. For example:

# prlctl create MyCT --vmtype ct --ostemplate centos-7-x86_64-mytmpl

If you created an application template, you now can add it to the container configuration file as described in Section 7.2.1, “Using Golden Image Functionality”.