Configuring container creation

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search

The creation of a container with vzctl needs three configuration files:

  • /etc/vz/vz.conf
  • /etc/vz/dists/distro-name.conf
  • /etc/vz/conf/ve-config-name.conf-sample

/etc/vz/vz.conf[edit]

There are two important lines in the file /etc/vz/vz.conf.

DEF_OSTEMPLATE[edit]

The first is DEF_OSTEMPLATE="distro" sets the default distribution used for container creation (i.e a default for --ostemplate argument). An example of distro is fedora-8-i386-minimal.

First, this provides the name of the tar file of container template cache: /vz/template/cache/distro.tar.gz.

Also, it gives the distribution configuration file, because unfortunately all distributions do not work the same way when setting the host name or the IP address. Several tries are done to find this configuration file name. Say, if distro is fedora-8-i386-minimal, then the following files are tried, in sequence:

  • /etc/vz/dists/fedora-8-i386-minimal.conf
  • /etc/vz/dists/fedora-8-i386.conf
  • /etc/vz/dists/fedora-8.conf
  • /etc/vz/dists/fedora.conf.

If not found, the /etc/vz/dists/default.conf is used (and the appropriate warning printed).

Information about the settings contained in these files can be found in /etc/vz/dists/distribution.conf-template.

CONFIGFILE[edit]

The other important line in the file /etc/vz/vz.conf is CONFIGFILE="config-name". It provides the name of the container configuration file: /etc/vz/conf/ve-config-name.conf-sample (for example, /etc/vz/conf/ve-light.conf-sample).

During container creation, this configuration file is copied to CTID.conf, for example, with CTID of 123: /etc/vz/conf/123.conf.

Whenever a parameter is changed for this container (vzctl set CTID --parameter newValue --save), parameter="newValue" line is added to (or replaced in) /etc/vz/conf/CTID.conf.

Once those three files are correctly set, creating a new container is just the command:

vzctl create CTID