Previous page

Next page

Locate page in Contents

Print this page

Setting Name for Container

You can assign an arbitrary name to a Container and use it, along with the Container ID, to perform Container-related operations. For example, you can start or stop a Container by specifying the Container name instead of its ID.

You can assign names to Containers using the --name option of the pctl set command. For example, to set the computer1 name for Container 101, run this 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:

  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, 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 must be put in single or double quotes.

Once you assign the computer1 name to Container 101, you can start using it instead of ID 101 to perform Container-related operations. 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 running 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 ):

    # 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:

    # grep NAME /etc/vz/names/computer1

    NAME="computer1"