Previous page

Next page

Locate page in Contents

Print this page

Setting Name for Container

You can assign an arbitrary name to your Container and use it, along with the Container ID, to refer to the Container while performing this or that Container-related operation on the server. For example, you can start or stop a Container by specifying the Container name instead of its ID.

You can assign names to your Containers using the --name option of the pctl set command. For example, to set the computer1 name for Container 101, you should execute the following command:

# pctl set 101 --name computer1 --save

Name computer1 assigned

Saved parameters for Container 101

You can also set a name for Container 101 by editing its configuration file. In this case you should proceed as follows:

  1. Open the configuration file of Container 101 ( /etc/vz/conf/101.conf ) for editing and add the following string to the file:

    NAME="computer1"

  2. In the /etc/vz/names directory on the server, create a symbolic link with the name of computer1 pointing to the Container configuration file. For example:

    # ln --symbolic /etc/vz/conf/101.conf /etc/vz/names/computer1

When specifying names for Containers, please keep in mind the following:

  • Names may contain the following symbols: a-z , A-Z , 0-9 , underscores ( _ ), dashes ( - ), spaces, the symbols from the ASCII character table with their code in the 128 - 255 range, and all the national alphabets included in the Unicode code space.
  • Container names cannot consist of digits only; otherwise, there would be no way to distinguish them from Container IDs.
  • If it contains one or more spaces, the Container name should be put in single or double quotes.

After the name has been successfully assigned to Container 101, you can start using it instead of ID 101 to perform Container-related operations on the Node. For example:

  • You can stop Container 101 with the following command:

    # pctl stop computer1

    Stopping Container ...
    Container was stopped
    Container is unmounted

  • You can start Container 101 anew by issuing the following command:

    # pctl start computer1

    Starting Container ...

    ...

You can find out what name is assigned to Container 101 in one of the following ways:

  • Using the vzlist utility:

    # vzlist -o name 101

    NAME

    computer1

  • Checking the NAME parameter in the Container configuration file ( /etc/vz/conf/101.conf ). For example:

    # grep NAME /etc/vz/conf/101.conf

    NAME="computer1"

  • Checking the NAME parameter in the /etc/vz/names/computer1 file which is a symlink to the Container configuration file. For example:

    # grep NAME /etc/vz/names/computer1

    NAME="computer1"