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:
-
Open the configuration file of Container 101 (
/etc/vz/conf/101.conf
) for editing, and add the following string to the file:
NAME="computer1"
-
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 find out what name is assigned to Container 101 in one of the following ways:
|